postit: persist settings save and apply ApiUrl changes without restart #51
1 changed files with 24 additions and 1 deletions
postit: harden oidc settings defaults on startup
commit
5fc99d73b0
|
|
@ -123,6 +123,8 @@ public partial class Settings : ViewModelBase
|
||||||
// build options from a torn read.
|
// build options from a torn read.
|
||||||
lock (_mutationGate)
|
lock (_mutationGate)
|
||||||
{
|
{
|
||||||
|
EnsureAuthenticationDefaultsLocked();
|
||||||
|
|
||||||
var options = new OidcClientOptions
|
var options = new OidcClientOptions
|
||||||
{
|
{
|
||||||
Authority = Authentication.Authority,
|
Authority = Authentication.Authority,
|
||||||
|
|
@ -151,6 +153,25 @@ public partial class Settings : ViewModelBase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void EnsureAuthenticationDefaultsLocked()
|
||||||
|
{
|
||||||
|
Authentication ??= new AuthenticationSettings();
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(Authentication.Authority))
|
||||||
|
Authentication.Authority = AuthenticationSettings.DefaultAuthority;
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(Authentication.ClientId))
|
||||||
|
Authentication.ClientId = AuthenticationSettings.DefaultClientId;
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(Authentication.RedirectUri))
|
||||||
|
Authentication.RedirectUri = AuthenticationSettings.DesktopRedirectUri;
|
||||||
|
|
||||||
|
if (Authentication.Scopes is null || Authentication.Scopes.Length == 0)
|
||||||
|
Authentication.Scopes = AuthenticationSettings.DefaultScopes;
|
||||||
|
|
||||||
|
Authentication.RefreshScopeListText();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Scopes the PostIt client always requires from the OIDC provider,
|
/// Scopes the PostIt client always requires from the OIDC provider,
|
||||||
/// regardless of what the user has in their settings file.
|
/// regardless of what the user has in their settings file.
|
||||||
|
|
@ -334,11 +355,13 @@ public partial class Settings : ViewModelBase
|
||||||
AuthenticationSettings.DesktopRedirectUri : settings.Authentication.RedirectUri;
|
AuthenticationSettings.DesktopRedirectUri : settings.Authentication.RedirectUri;
|
||||||
if (settings.Authentication.Scopes is null || settings.Authentication.Scopes.Length == 0)
|
if (settings.Authentication.Scopes is null || settings.Authentication.Scopes.Length == 0)
|
||||||
{
|
{
|
||||||
settings.Authentication.Scopes = AuthenticationSettings.DefaultScopes;
|
this.Authentication.Scopes = AuthenticationSettings.DefaultScopes;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
this.Authentication.Scopes = settings.Authentication.Scopes;
|
this.Authentication.Scopes = settings.Authentication.Scopes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EnsureAuthenticationDefaultsLocked();
|
||||||
}
|
}
|
||||||
// A disk load (or an embedded-resource fallback) is the
|
// A disk load (or an embedded-resource fallback) is the
|
||||||
// baseline, not a user edit. Clear the dirty flag last
|
// baseline, not a user edit. Clear the dirty flag last
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue