diff --git a/8.0/BlazorWebAssemblyStandaloneWithIdentity/BlazorWasmAuth/Identity/CookieAuthenticationStateProvider.cs b/8.0/BlazorWebAssemblyStandaloneWithIdentity/BlazorWasmAuth/Identity/CookieAuthenticationStateProvider.cs index 4da7b6f55..bd306d289 100644 --- a/8.0/BlazorWebAssemblyStandaloneWithIdentity/BlazorWasmAuth/Identity/CookieAuthenticationStateProvider.cs +++ b/8.0/BlazorWebAssemblyStandaloneWithIdentity/BlazorWasmAuth/Identity/CookieAuthenticationStateProvider.cs @@ -14,7 +14,8 @@ namespace BlazorWasmAuth.Identity /// Create a new instance of the auth provider. /// /// Factory to retrieve auth client. - public class CookieAuthenticationStateProvider(IHttpClientFactory httpClientFactory) : AuthenticationStateProvider, IAccountManagement + public class CookieAuthenticationStateProvider(IHttpClientFactory httpClientFactory, ILogger logger) + : AuthenticationStateProvider, IAccountManagement { /// /// Map the JavaScript-formatted properties to C#-formatted classes. @@ -95,7 +96,10 @@ public async Task RegisterAsync(string email, string password) ErrorList = problemDetails == null ? defaultDetail : [.. errors] }; } - catch { } + catch (Exception ex) + { + logger.LogError(ex, "App error"); + } // unknown error return new FormResult @@ -133,7 +137,10 @@ public async Task LoginAsync(string email, string password) return new FormResult { Succeeded = true }; } } - catch { } + catch (Exception ex) + { + logger.LogError(ex, "App error"); + } // unknown error return new FormResult @@ -214,7 +221,10 @@ public override async Task GetAuthenticationStateAsync() authenticated = true; } } - catch { } + catch (Exception ex) + { + logger.LogError(ex, "App error"); + } // return the state return new AuthenticationState(user); @@ -233,14 +243,5 @@ public async Task CheckAuthenticatedAsync() await GetAuthenticationStateAsync(); return authenticated; } - - public class RoleClaim - { - public string? Issuer { get; set; } - public string? OriginalIssuer { get; set; } - public string? Type { get; set; } - public string? Value { get; set; } - public string? ValueType { get; set; } - } } } diff --git a/8.0/BlazorWebAssemblyStandaloneWithIdentity/BlazorWasmAuth/Identity/Models/RoleClaim.cs b/8.0/BlazorWebAssemblyStandaloneWithIdentity/BlazorWasmAuth/Identity/Models/RoleClaim.cs new file mode 100644 index 000000000..a320e8fba --- /dev/null +++ b/8.0/BlazorWebAssemblyStandaloneWithIdentity/BlazorWasmAuth/Identity/Models/RoleClaim.cs @@ -0,0 +1,11 @@ +namespace BlazorWasmAuth.Identity.Models +{ + public class RoleClaim + { + public string? Issuer { get; set; } + public string? OriginalIssuer { get; set; } + public string? Type { get; set; } + public string? Value { get; set; } + public string? ValueType { get; set; } + } +} diff --git a/9.0/BlazorWebAssemblyStandaloneWithIdentity/BlazorWasmAuth/Identity/CookieAuthenticationStateProvider.cs b/9.0/BlazorWebAssemblyStandaloneWithIdentity/BlazorWasmAuth/Identity/CookieAuthenticationStateProvider.cs index 4da7b6f55..bd306d289 100644 --- a/9.0/BlazorWebAssemblyStandaloneWithIdentity/BlazorWasmAuth/Identity/CookieAuthenticationStateProvider.cs +++ b/9.0/BlazorWebAssemblyStandaloneWithIdentity/BlazorWasmAuth/Identity/CookieAuthenticationStateProvider.cs @@ -14,7 +14,8 @@ namespace BlazorWasmAuth.Identity /// Create a new instance of the auth provider. /// /// Factory to retrieve auth client. - public class CookieAuthenticationStateProvider(IHttpClientFactory httpClientFactory) : AuthenticationStateProvider, IAccountManagement + public class CookieAuthenticationStateProvider(IHttpClientFactory httpClientFactory, ILogger logger) + : AuthenticationStateProvider, IAccountManagement { /// /// Map the JavaScript-formatted properties to C#-formatted classes. @@ -95,7 +96,10 @@ public async Task RegisterAsync(string email, string password) ErrorList = problemDetails == null ? defaultDetail : [.. errors] }; } - catch { } + catch (Exception ex) + { + logger.LogError(ex, "App error"); + } // unknown error return new FormResult @@ -133,7 +137,10 @@ public async Task LoginAsync(string email, string password) return new FormResult { Succeeded = true }; } } - catch { } + catch (Exception ex) + { + logger.LogError(ex, "App error"); + } // unknown error return new FormResult @@ -214,7 +221,10 @@ public override async Task GetAuthenticationStateAsync() authenticated = true; } } - catch { } + catch (Exception ex) + { + logger.LogError(ex, "App error"); + } // return the state return new AuthenticationState(user); @@ -233,14 +243,5 @@ public async Task CheckAuthenticatedAsync() await GetAuthenticationStateAsync(); return authenticated; } - - public class RoleClaim - { - public string? Issuer { get; set; } - public string? OriginalIssuer { get; set; } - public string? Type { get; set; } - public string? Value { get; set; } - public string? ValueType { get; set; } - } } } diff --git a/9.0/BlazorWebAssemblyStandaloneWithIdentity/BlazorWasmAuth/Identity/Models/RoleClaim.cs b/9.0/BlazorWebAssemblyStandaloneWithIdentity/BlazorWasmAuth/Identity/Models/RoleClaim.cs new file mode 100644 index 000000000..a320e8fba --- /dev/null +++ b/9.0/BlazorWebAssemblyStandaloneWithIdentity/BlazorWasmAuth/Identity/Models/RoleClaim.cs @@ -0,0 +1,11 @@ +namespace BlazorWasmAuth.Identity.Models +{ + public class RoleClaim + { + public string? Issuer { get; set; } + public string? OriginalIssuer { get; set; } + public string? Type { get; set; } + public string? Value { get; set; } + public string? ValueType { get; set; } + } +}