From 9619cad38e2176e0690bc2756491b6ff68537206 Mon Sep 17 00:00:00 2001 From: Nick Randolph Date: Sat, 16 Mar 2024 00:03:29 +1100 Subject: [PATCH] feat: Adding logging when unable to launch login or logout flows --- .../Web/WebAuthenticationProvider.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Uno.Extensions.Authentication.UI/Web/WebAuthenticationProvider.cs b/src/Uno.Extensions.Authentication.UI/Web/WebAuthenticationProvider.cs index b0c00f5ece..aecd2566a2 100644 --- a/src/Uno.Extensions.Authentication.UI/Web/WebAuthenticationProvider.cs +++ b/src/Uno.Extensions.Authentication.UI/Web/WebAuthenticationProvider.cs @@ -51,6 +51,10 @@ private WebAuthenticationSettings InternalSettings if (loginStartUri is null || string.IsNullOrWhiteSpace(loginStartUri)) { + if (ProviderLogger.IsEnabled(LogLevel.Warning)) + { + ProviderLogger.LogWarning($"{nameof(InternalSettings.LoginStartUri)} not specified, unable to start login flow"); + } return default; } @@ -68,6 +72,10 @@ private WebAuthenticationSettings InternalSettings if (string.IsNullOrWhiteSpace(loginCallbackUri)) { + if (ProviderLogger.IsEnabled(LogLevel.Warning)) + { + ProviderLogger.LogWarning($"{nameof(InternalSettings.LoginCallbackUri)} not specified and {OAuthRedirectUriParameter} not set in {nameof(InternalSettings.LoginStartUri)}, unable to start login flow"); + } return default; } @@ -153,7 +161,11 @@ protected async override ValueTask InternalLogoutAsync(IDispatcher? dispat if (logoutStartUri is null || string.IsNullOrWhiteSpace(logoutStartUri)) { - return true; + if (ProviderLogger.IsEnabled(LogLevel.Warning)) + { + ProviderLogger.LogWarning($"{nameof(InternalSettings.LogoutStartUri)} not specified, unable to start logout flow"); + } + return false; } var logoutCallbackUri = InternalSettings.LogoutCallbackUri ?? InternalSettings.LoginCallbackUri; @@ -177,6 +189,10 @@ InternalSettings.LoginStartUri is { } loginStartUri && if (string.IsNullOrWhiteSpace(logoutCallbackUri)) { + if (ProviderLogger.IsEnabled(LogLevel.Warning)) + { + ProviderLogger.LogWarning($"{nameof(InternalSettings.LogoutCallbackUri)} not specified and {OAuthRedirectUriParameter} not set in {nameof(InternalSettings.LogoutStartUri)}, unable to start logout flow"); + } return false; }