Website Summary Files Commits Branches @commit @diff @stats
path: root / ExamTemplate / Web / Controllers / UserController.cs
diff options
context:
space:
mode:
Commit756889d2023c584a847b48b498279c702b1adaf0 (patch)
Author
 Syndamia <kamen.d.mladenov@protonmail.com>
2021-05-07 15:46:55 +0300
Committer
 Syndamia <kamen.d.mladenov@protonmail.com>
2021-05-07 15:46:55 +0300
Files6dd234957154ede9621af6e464201f642c168434 /ExamTemplate/Web/Controllers/UserController.cs
it-kariera-exam-template-756889d2023c584a847b48b498279c702b1adaf0.tar
it-kariera-exam-template-756889d2023c584a847b48b498279c702b1adaf0.tar.gz
it-kariera-exam-template-756889d2023c584a847b48b498279c702b1adaf0.zip
Parentd066d187f9e3348d56d0752d7a3966fbf5ff88f7 (diff)
User now gets logged out only when they change their username
1 files changed, 6 insertions, 5 deletions
-rw-r--r--ExamTemplate/Web/Controllers/UserController.cs11
diff --git a/ExamTemplate/Web/Controllers/UserController.cs b/ExamTemplate/Web/Controllers/UserController.cs
index c855c39..4d245f7 100644
--- a/ExamTemplate/Web/Controllers/UserController.cs
+++ b/ExamTemplate/Web/Controllers/UserController.cs
@@ -112,19 +112,20 @@ namespace ExamTemplate.Web.Controllers
if (!this._userService.IsSignedIn(HttpContext.User))
return RedirectToAction("Login");
+ UserServiceModel loggedInUser = await this._userService.GetUserByClaimsAsync(HttpContext.User);
+
EditUserServiceModel editUserServiceModel = this._autoMapper.Map<EditUserServiceModel>(editUserViewModel);
bool result = await this._userService.EditUserAsync(HttpContext.User, editUserServiceModel);
if (result)
{
- await this._userService.LogoutAsync();
+ if (loggedInUser.Username != editUserViewModel.Username)
+ await this._userService.LogoutAsync();
+
return RedirectToAction("Profile", new { username = editUserViewModel.Username });
}
else
- {
- UserServiceModel userServiceModel = await this._userService.GetUserByClaimsAsync(HttpContext.User);
- return RedirectToAction("Profile", new { username = userServiceModel.Username });
- }
+ return RedirectToAction("Profile", new { username = loggedInUser.Username });
}
}
}