From ecbfb8cd55ac718f75787817f6fdb833234e6a57 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sat, 8 May 2021 18:24:48 +0300 Subject: Simplified account edit authorization --- ExamTemplate/Services/UserService.cs | 7 ------- ExamTemplate/Web/Controllers/AccountController.cs | 3 --- 2 files changed, 10 deletions(-) (limited to 'ExamTemplate') diff --git a/ExamTemplate/Services/UserService.cs b/ExamTemplate/Services/UserService.cs index e78443a..2f137a1 100644 --- a/ExamTemplate/Services/UserService.cs +++ b/ExamTemplate/Services/UserService.cs @@ -81,12 +81,5 @@ namespace ExamTemplate.Services { return this._signInManager.IsSignedIn(claimsPrincipal); } - - public async Task IsAuthorizedToModify(ClaimsPrincipal claimsPrincipal, string username) - { - User user = await this._userManager.GetUserAsync(claimsPrincipal); - - return user.UserName == username || await this._userManager.IsInRoleAsync(user, "Administrator"); - } } } diff --git a/ExamTemplate/Web/Controllers/AccountController.cs b/ExamTemplate/Web/Controllers/AccountController.cs index 7fb7ab3..0424070 100644 --- a/ExamTemplate/Web/Controllers/AccountController.cs +++ b/ExamTemplate/Web/Controllers/AccountController.cs @@ -106,9 +106,6 @@ namespace ExamTemplate.Web.Controllers [HttpPost] public async Task Edit(EditUserViewModel editUserViewModel) { - if (!await this._userService.IsAuthorizedToModify(HttpContext.User, editUserViewModel.OriginalUsername)) - return new UnauthorizedResult(); - if (!ModelState.IsValid) return View(editUserViewModel); -- cgit v1.2.3