Cleanup login page, custom button text

This commit is contained in:
Amelia 2025-06-30 20:27:53 +02:00
parent 54fb4c7a8a
commit 4c0faa755d
No known key found for this signature in database
GPG key ID: D6D0ECE365407EAA
12 changed files with 76 additions and 32 deletions

View file

@ -3,12 +3,8 @@ using API.Entities.Enums;
namespace API.DTOs.Settings;
public class OidcConfigDto
public record OidcConfigDto: OidcPublicConfigDto
{
/// <inheritdoc cref="ServerSettingKey.OidcAuthority"/>
public string? Authority { get; set; }
/// <inheritdoc cref="ServerSettingKey.OidcClientId"/>
public string? ClientId { get; set; }
/// <inheritdoc cref="ServerSettingKey.OidcProvisionAccounts"/>
public bool ProvisionAccounts { get; set; }
/// <inheritdoc cref="ServerSettingKey.OidcRequireVerifiedEmail"/>
@ -16,12 +12,9 @@ public class OidcConfigDto
/// <inheritdoc cref="ServerSettingKey.OidcProvisionUserSettings"/>
public bool ProvisionUserSettings { get; set; }
/// <inheritdoc cref="ServerSettingKey.OidcAutoLogin"/>
public bool AutoLogin { get; set; }
/// <inheritdoc cref="ServerSettingKey.DisablePasswordAuthentication"/>
public bool DisablePasswordAuthentication { get; set; }
/// <summary>
/// Returns true if the <see cref="Authority"/> has been set
/// Returns true if the <see cref="OidcPublicConfigDto.Authority"/> has been set
/// </summary>
public bool Enabled => Authority != "";
}

View file

@ -1,14 +1,18 @@
#nullable enable
using API.Entities.Enums;
namespace API.DTOs.Settings;
public sealed record OidcPublicConfigDto
public record OidcPublicConfigDto
{
/// <inheritdoc cref="OidcConfigDto.Authority"/>
/// <inheritdoc cref="ServerSettingKey.OidcAuthority"/>
public string? Authority { get; set; }
/// <inheritdoc cref="OidcConfigDto.ClientId"/>
/// <inheritdoc cref="ServerSettingKey.OidcClientId"/>
public string? ClientId { get; set; }
/// <inheritdoc cref="OidcConfigDto.AutoLogin"/>
/// <inheritdoc cref="ServerSettingKey.OidcAutoLogin"/>
public bool AutoLogin { get; set; }
/// <inheritdoc cref="OidcConfigDto.DisablePasswordAuthentication"/>
/// <inheritdoc cref="ServerSettingKey.DisablePasswordAuthentication"/>
public bool DisablePasswordAuthentication { get; set; }
/// <inheritdoc cref="ServerSettingKey.OidcProviderName"/>
public string ProviderName { get; set; } = string.Empty;
}

View file

@ -259,6 +259,7 @@ public static class Seed
new() { Key = ServerSettingKey.OidcRequireVerifiedEmail, Value = "true"},
new() { Key = ServerSettingKey.OidcProvisionUserSettings, Value = "false"},
new() { Key = ServerSettingKey.DisablePasswordAuthentication, Value = "false"},
new() { Key = ServerSettingKey.OidcProviderName, Value = "OpenID Connect"},
new() {Key = ServerSettingKey.EmailHost, Value = string.Empty},
new() {Key = ServerSettingKey.EmailPort, Value = string.Empty},

View file

@ -232,4 +232,10 @@ public enum ServerSettingKey
/// </summary>
[Description("DisablePasswordAuthentication")]
DisablePasswordAuthentication = 46,
/// <summary>
/// Name of your provider, used to display on the login screen
/// </summary>
/// <remarks>Default to OpenID Connect</remarks>
[Description("OidcProviderName")]
OidcProviderName = 47,
}

View file

@ -157,6 +157,10 @@ public class ServerSettingConverter : ITypeConverter<IEnumerable<ServerSetting>,
destination.OidcConfig ??= new OidcConfigDto();
destination.OidcConfig.DisablePasswordAuthentication = bool.Parse(row.Value);
break;
case ServerSettingKey.OidcProviderName:
destination.OidcConfig ??= new OidcConfigDto();
destination.OidcConfig.ProviderName = row.Value;
break;
case ServerSettingKey.LicenseKey:
case ServerSettingKey.EnableAuthentication:
case ServerSettingKey.EmailServiceUrl:

View file

@ -464,6 +464,13 @@ public class SettingsService : ISettingsService
_unitOfWork.SettingsRepository.Update(setting);
}
if (setting.Key == ServerSettingKey.OidcProviderName &&
updateSettingsDto.OidcConfig.ProviderName + string.Empty != setting.Value)
{
setting.Value = updateSettingsDto.OidcConfig.ProviderName + string.Empty;
_unitOfWork.SettingsRepository.Update(setting);
}
}
private void UpdateEmailSettings(ServerSetting setting, ServerSettingDto updateSettingsDto)