From 87815ca5dc0a44fadbbe71d69fe173cb151428f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Fi=C5=A1era?= Date: Wed, 10 Jun 2020 18:48:54 +0200 Subject: [PATCH] #295 - After successful login, token validation is omitted. --- .../Services/ApiAuthenticationStateProvider.cs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Money.UI.Blazor/Services/ApiAuthenticationStateProvider.cs b/src/Money.UI.Blazor/Services/ApiAuthenticationStateProvider.cs index 698b763f..29361204 100644 --- a/src/Money.UI.Blazor/Services/ApiAuthenticationStateProvider.cs +++ b/src/Money.UI.Blazor/Services/ApiAuthenticationStateProvider.cs @@ -66,7 +66,7 @@ public async Task 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)) @@ -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) @@ -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());