Compare commits
No commits in common. "2036b2afabb182fd01c606c162f021b59dcce042" and "d55b232e00ab7061a0080458b91879bbf923be1a" have entirely different histories.
2036b2afab
...
d55b232e00
|
|
@ -2,7 +2,6 @@
|
||||||
@using TIAMWebApp.Shared.Application.Interfaces
|
@using TIAMWebApp.Shared.Application.Interfaces
|
||||||
@using AyCode.Interfaces.StorageHandlers
|
@using AyCode.Interfaces.StorageHandlers
|
||||||
@using Microsoft.Extensions.Localization
|
@using Microsoft.Extensions.Localization
|
||||||
@using Microsoft.AspNetCore.Components.Authorization
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -100,15 +99,7 @@
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
<ul class="nav navbar-nav navbar-right">
|
<ul class="nav navbar-nav navbar-right">
|
||||||
<AuthorizeView>
|
|
||||||
<Authorized>
|
|
||||||
<li class="nav-item">
|
|
||||||
<NavLink class="nav-link" href="login">
|
|
||||||
Test
|
|
||||||
</NavLink>
|
|
||||||
</li>
|
|
||||||
</Authorized>
|
|
||||||
</AuthorizeView>
|
|
||||||
@if(enableLogin)
|
@if(enableLogin)
|
||||||
{
|
{
|
||||||
if (!myUser && enableLogin)
|
if (!myUser && enableLogin)
|
||||||
|
|
|
||||||
|
|
@ -93,8 +93,7 @@ namespace TIAMSharedUI.Shared.Components
|
||||||
serverResult = await UserDataService.Logout(userBasicDetail.RefreshToken);
|
serverResult = await UserDataService.Logout(userBasicDetail.RefreshToken);
|
||||||
}
|
}
|
||||||
await SecureStorageHandler.ClearAllSecureStorageAsync();
|
await SecureStorageHandler.ClearAllSecureStorageAsync();
|
||||||
var result = await AuthStateProvider.GetAuthenticationStateAsync();
|
await AuthStateProvider.GetAuthenticationStateAsync();
|
||||||
|
|
||||||
sessionService.User = null;
|
sessionService.User = null;
|
||||||
sessionService.IsAuthenticated = false;
|
sessionService.IsAuthenticated = false;
|
||||||
navigationManager.NavigateTo("/");
|
navigationManager.NavigateTo("/");
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ namespace TIAMWebApp.Shared.Application.Services
|
||||||
private readonly ISecureStorageHandler _localStorage;
|
private readonly ISecureStorageHandler _localStorage;
|
||||||
private readonly HttpClient _http;
|
private readonly HttpClient _http;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public CustomAuthStateProvider(ISecureStorageHandler localStorage, HttpClient http)
|
public CustomAuthStateProvider(ISecureStorageHandler localStorage, HttpClient http)
|
||||||
{
|
{
|
||||||
|
|
@ -27,31 +28,30 @@ namespace TIAMWebApp.Shared.Application.Services
|
||||||
AuthenticationState state = null;
|
AuthenticationState state = null;
|
||||||
if (!string.IsNullOrEmpty(userDetailsStr))
|
if (!string.IsNullOrEmpty(userDetailsStr))
|
||||||
{
|
{
|
||||||
|
|
||||||
|
var userBasicDetail = JsonConvert.DeserializeObject<UserBasicDetails>(userDetailsStr);
|
||||||
|
|
||||||
var userBasicDetail = JsonConvert.DeserializeObject<UserBasicDetails>(userDetailsStr);
|
//var handler = new JwtSecurityTokenHandler();
|
||||||
|
//var jsontoken = handler.ReadToken(userBasicDetail?.AccessToken) as JwtSecurityToken;
|
||||||
|
var token = userBasicDetail?.AccessToken;
|
||||||
|
var identity = new ClaimsIdentity();
|
||||||
|
_http.DefaultRequestHeaders.Authorization = null;
|
||||||
|
|
||||||
//var handler = new JwtSecurityTokenHandler();
|
if (!string.IsNullOrEmpty(token))
|
||||||
//var jsontoken = handler.ReadToken(userBasicDetail?.AccessToken) as JwtSecurityToken;
|
{
|
||||||
var token = userBasicDetail?.AccessToken;
|
identity = new ClaimsIdentity(ParseClaimsFromJwt(token), "jwt");
|
||||||
var identity = new ClaimsIdentity();
|
_http.DefaultRequestHeaders.Authorization =
|
||||||
_http.DefaultRequestHeaders.Authorization = null;
|
new AuthenticationHeaderValue("Bearer", token.Replace("\"", ""));
|
||||||
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(token))
|
var user = new ClaimsPrincipal(identity);
|
||||||
{
|
state = new AuthenticationState(user);
|
||||||
identity = new ClaimsIdentity(ParseClaimsFromJwt(token), "jwt");
|
|
||||||
_http.DefaultRequestHeaders.Authorization =
|
|
||||||
new AuthenticationHeaderValue("Bearer", token.Replace("\"", ""));
|
|
||||||
}
|
|
||||||
|
|
||||||
var user = new ClaimsPrincipal(identity);
|
NotifyAuthenticationStateChanged(Task.FromResult(state));
|
||||||
state = new AuthenticationState(user);
|
|
||||||
|
|
||||||
NotifyAuthenticationStateChanged(Task.FromResult(state));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
state = new AuthenticationState(new ClaimsPrincipal());
|
state = new AuthenticationState(new ClaimsPrincipal());
|
||||||
NotifyAuthenticationStateChanged(Task.FromResult(state));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return state;
|
return state;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue