Skip to content

Commit 621cef7

Browse files
committed
✨IIdentityService
1 parent fa69bd7 commit 621cef7

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

src/Application/Common/Interfaces/Identity/IIdentityService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace CleanArchitecture.Blazor.Application.Common.Interfaces.Identity;
1111
public interface IIdentityService : IService
1212
{
1313
Task<Result<TokenResponse>> LoginAsync(TokenRequest request, CancellationToken cancellation = default);
14-
Task<string> GenerateJwtAsync(ApplicationUser user);
14+
Task<TokenResponse> GenerateJwtAsync(ApplicationUser user);
1515
Task<Result<TokenResponse>> RefreshTokenAsync(RefreshTokenRequest request, CancellationToken cancellation = default);
1616
Task<ClaimsPrincipal> GetClaimsPrincipal(string token);
1717
Task<string?> GetUserNameAsync(string userId, CancellationToken cancellation = default);

src/Infrastructure/Services/Identity/IdentityService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ private string GenerateRefreshToken()
173173
rng.GetBytes(randomNumber);
174174
return Convert.ToBase64String(randomNumber);
175175
}
176-
public async Task<string> GenerateJwtAsync(ApplicationUser user)
176+
public async Task<TokenResponse> GenerateJwtAsync(ApplicationUser user)
177177
{
178178
var principal = await _userClaimsPrincipalFactory.CreateAsync(user);
179179
var token = GenerateEncryptedToken(GetSigningCredentials(), principal.Claims);

src/Infrastructure/Services/JWT/AccessTokenProvider.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ public AccessTokenProvider(ProtectedLocalStorage localStorage, NavigationManager
3030
}
3131
public async Task GenerateJwt(ApplicationUser applicationUser)
3232
{
33-
AccessToken = await _identityService.GenerateJwtAsync(applicationUser);
34-
await _localStorage.SetAsync(_tokenKey, AccessToken);
33+
var token = await _identityService.GenerateJwtAsync(applicationUser,true);
34+
await _localStorage.SetAsync(_tokenKey, token.Token);
35+
await _localStorage.SetAsync(_refreshTokenKey, token.RefreshToken);
3536
_tenantProvider.TenantId = applicationUser.TenantId;
3637
_tenantProvider.TenantName = applicationUser.TenantName;
3738
_currentUser.UserId = applicationUser.Id;

0 commit comments

Comments
 (0)