Skip to content

Commit

Permalink
#295 - After successful login, token validation is omitted.
Browse files Browse the repository at this point in the history
  • Loading branch information
maraf committed Jun 10, 2020
1 parent 34126b6 commit 87815ca
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/Money.UI.Blazor/Services/ApiAuthenticationStateProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public async Task<string> GetTokenAsync()
return token.Value;
}

private async Task ChangeTokenAsync(string value)
private async Task ChangeTokenAsync(string value, bool isValidationRequired = true)
{
token.Value = value;
if (!String.IsNullOrEmpty(token.Value))
Expand All @@ -76,10 +76,13 @@ private async Task ChangeTokenAsync(string value)
http.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Value);

bool isValid = true;
if (!await ValidateTokenAsync(token.Value))
if (isValidationRequired)
{
log.Debug("Token isn't valid.");
isValid = false;
if (!await ValidateTokenAsync(token.Value))
{
log.Debug("Token isn't valid.");
isValid = false;
}
}

if (isValid)
Expand Down Expand Up @@ -114,7 +117,7 @@ public async Task SetTokenAsync(string value, bool isPersistent = false)
if (isPersistent)
await interop.SaveTokenAsync(value);

await ChangeTokenAsync(value);
await ChangeTokenAsync(value, false);

log.Debug("NotifyAuthenticationStateChanged.");
NotifyAuthenticationStateChanged(GetAuthenticationStateAsync());
Expand Down

0 comments on commit 87815ca

Please sign in to comment.