Patch UI ProviderJWT
All checks were successful
CI/CD Pipeline / Build and Deploy with Docker Compose (push) Successful in 8m3s
All checks were successful
CI/CD Pipeline / Build and Deploy with Docker Compose (push) Successful in 8m3s
This commit is contained in:
parent
5e7c71874a
commit
4ae39a9ff2
@ -73,14 +73,26 @@ namespace phronCare.UIBlazor.Services.Authorization
|
||||
// };
|
||||
//}
|
||||
|
||||
public async Task Login(string token)
|
||||
//public async Task Login(string token)
|
||||
//{
|
||||
// await js.RemoveItem(TOKENKEY);
|
||||
// await js.SetInLocalStorage(TOKENKEY, token);
|
||||
// var authState = BuildAuthenticationState(token);
|
||||
// NotifyAuthenticationStateChanged(Task.FromResult(authState));
|
||||
//}
|
||||
public async Task Login(string tokenJson)
|
||||
{
|
||||
var tokenData = JsonSerializer.Deserialize<TokenData>(tokenJson);
|
||||
|
||||
if (tokenData is null || string.IsNullOrWhiteSpace(tokenData.token))
|
||||
throw new Exception("Token inválido o mal formado.");
|
||||
|
||||
await js.RemoveItem(TOKENKEY);
|
||||
await js.SetInLocalStorage(TOKENKEY, token);
|
||||
var authState = BuildAuthenticationState(token);
|
||||
await js.SetInLocalStorage(TOKENKEY, tokenData.token); // ✔️ Guardamos solo el JWT string
|
||||
|
||||
var authState = BuildAuthenticationState(tokenData.token);
|
||||
NotifyAuthenticationStateChanged(Task.FromResult(authState));
|
||||
}
|
||||
|
||||
public async Task Logout()
|
||||
{
|
||||
httpClient.DefaultRequestHeaders.Authorization = null;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user