Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ namespace BlazorWasmAuth.Identity
/// Create a new instance of the auth provider.
/// </remarks>
/// <param name="httpClientFactory">Factory to retrieve auth client.</param>
public class CookieAuthenticationStateProvider(IHttpClientFactory httpClientFactory) : AuthenticationStateProvider, IAccountManagement
public class CookieAuthenticationStateProvider(IHttpClientFactory httpClientFactory, ILogger<CookieAuthenticationStateProvider> logger)
: AuthenticationStateProvider, IAccountManagement
{
/// <summary>
/// Map the JavaScript-formatted properties to C#-formatted classes.
Expand Down Expand Up @@ -95,7 +96,10 @@ public async Task<FormResult> RegisterAsync(string email, string password)
ErrorList = problemDetails == null ? defaultDetail : [.. errors]
};
}
catch { }
catch (Exception ex)
{
logger.LogError(ex, "App error");
}

// unknown error
return new FormResult
Expand Down Expand Up @@ -133,7 +137,10 @@ public async Task<FormResult> LoginAsync(string email, string password)
return new FormResult { Succeeded = true };
}
}
catch { }
catch (Exception ex)
{
logger.LogError(ex, "App error");
}

// unknown error
return new FormResult
Expand Down Expand Up @@ -214,7 +221,10 @@ public override async Task<AuthenticationState> GetAuthenticationStateAsync()
authenticated = true;
}
}
catch { }
catch (Exception ex)
{
logger.LogError(ex, "App error");
}

// return the state
return new AuthenticationState(user);
Expand All @@ -233,14 +243,5 @@ public async Task<bool> 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; }
}
}
}
Original file line number Diff line number Diff line change
@@ -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; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ namespace BlazorWasmAuth.Identity
/// Create a new instance of the auth provider.
/// </remarks>
/// <param name="httpClientFactory">Factory to retrieve auth client.</param>
public class CookieAuthenticationStateProvider(IHttpClientFactory httpClientFactory) : AuthenticationStateProvider, IAccountManagement
public class CookieAuthenticationStateProvider(IHttpClientFactory httpClientFactory, ILogger<CookieAuthenticationStateProvider> logger)
: AuthenticationStateProvider, IAccountManagement
{
/// <summary>
/// Map the JavaScript-formatted properties to C#-formatted classes.
Expand Down Expand Up @@ -95,7 +96,10 @@ public async Task<FormResult> RegisterAsync(string email, string password)
ErrorList = problemDetails == null ? defaultDetail : [.. errors]
};
}
catch { }
catch (Exception ex)
{
logger.LogError(ex, "App error");
}

// unknown error
return new FormResult
Expand Down Expand Up @@ -133,7 +137,10 @@ public async Task<FormResult> LoginAsync(string email, string password)
return new FormResult { Succeeded = true };
}
}
catch { }
catch (Exception ex)
{
logger.LogError(ex, "App error");
}

// unknown error
return new FormResult
Expand Down Expand Up @@ -214,7 +221,10 @@ public override async Task<AuthenticationState> GetAuthenticationStateAsync()
authenticated = true;
}
}
catch { }
catch (Exception ex)
{
logger.LogError(ex, "App error");
}

// return the state
return new AuthenticationState(user);
Expand All @@ -233,14 +243,5 @@ public async Task<bool> 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; }
}
}
}
Original file line number Diff line number Diff line change
@@ -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; }
}
}