Correct bunch of issues (#36)
All checks were successful
Game Ideas deploy / build-test-deploy (push) Successful in 1m28s
All checks were successful
Game Ideas deploy / build-test-deploy (push) Successful in 1m28s
Reviewed-on: #36
This commit was merged in pull request #36.
This commit is contained in:
@@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Components.Authorization;
|
||||
using System.Security.Claims;
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
using GameIdeas.Shared.Constants;
|
||||
using GameIdeas.Shared.Dto;
|
||||
|
||||
namespace GameIdeas.BlazorApp.Services;
|
||||
|
||||
@@ -31,9 +32,17 @@ public class JwtAuthenticationStateProvider(ILocalStorageService localStorage) :
|
||||
return new AuthenticationState(new ClaimsPrincipal(new ClaimsIdentity()));
|
||||
}
|
||||
|
||||
public async Task NotifyUserAuthenticationAsync(string token)
|
||||
public async Task NotifyUserAuthenticationAsync(TokenDto token)
|
||||
{
|
||||
await localStorage.SetItemAsStringAsync(GlobalConstants.LS_AUTH_STORAGE_KEY, token);
|
||||
if (token?.Token != null)
|
||||
{
|
||||
await localStorage.SetItemAsStringAsync(GlobalConstants.LS_AUTH_STORAGE_KEY, token.Token);
|
||||
}
|
||||
|
||||
if (token?.Expiration != null)
|
||||
{
|
||||
await localStorage.SetItemAsStringAsync(GlobalConstants.LS_EXPIRED_STORAGE_KEY, token.Expiration.Value.ToString());
|
||||
}
|
||||
|
||||
NotifyAuthenticationStateChanged(GetAuthenticationStateAsync());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user