From 0e960715ee22f0f9571af0c78030fd31bff96d29 Mon Sep 17 00:00:00 2001 From: "DESKTOP-GENO133\\IvanPlex" Date: Wed, 28 Feb 2024 16:20:01 -0700 Subject: [PATCH] Delete token only if user save is successful and log user out after updating profile. --- Logic/LoginLogic.cs | 4 ++-- wwwroot/js/garage.js | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Logic/LoginLogic.cs b/Logic/LoginLogic.cs index d69c7f5..01ea532 100644 --- a/Logic/LoginLogic.cs +++ b/Logic/LoginLogic.cs @@ -75,8 +75,6 @@ namespace CarCareTracker.Logic { return new OperationResponse { Success = false, Message = "Invalid Token" }; } - //token is valid, delete it. - _tokenData.DeleteToken(existingToken.Id); if (!string.IsNullOrWhiteSpace(credentials.UserName) && existingUser.UserName != credentials.UserName) { //check if new username is already taken. @@ -102,6 +100,8 @@ namespace CarCareTracker.Logic //update password existingUser.Password = GetHash(credentials.Password); } + //delete token + _tokenData.DeleteToken(existingToken.Id); var result = _userData.SaveUserRecord(existingUser); return new OperationResponse { Success = result, Message = result ? "User Updated" : StaticHelper.GenericErrorMessage }; } diff --git a/wwwroot/js/garage.js b/wwwroot/js/garage.js index 80240f3..714c4f9 100644 --- a/wwwroot/js/garage.js +++ b/wwwroot/js/garage.js @@ -395,7 +395,8 @@ function validateAndSaveUserAccount() { if (data.success) { //hide modal hideAccountInformationModal(); - successToast('Profile Updated') + successToast('Profile Updated'); + performLogOut(); } else { errorToast(data.message); }