From 5f2abdf275c3765290ee7d6728842cba6d3af184 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Fri, 7 May 2021 15:27:34 +0300 Subject: Implemented editing user --- ExamTemplate/Data/Repositories/UserRepository.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'ExamTemplate/Data/Repositories/UserRepository.cs') diff --git a/ExamTemplate/Data/Repositories/UserRepository.cs b/ExamTemplate/Data/Repositories/UserRepository.cs index 04e1f45..3e5ceaa 100644 --- a/ExamTemplate/Data/Repositories/UserRepository.cs +++ b/ExamTemplate/Data/Repositories/UserRepository.cs @@ -1,3 +1,4 @@ +using System.Security.Claims; using System.Threading.Tasks; using ExamTemplate.Data.Models; using Microsoft.AspNetCore.Identity; @@ -25,6 +26,11 @@ namespace ExamTemplate.Data.Repositories .FirstOrDefaultAsync(x => x.UserName == username); } + public async Task GetByClaimsAsync(ClaimsPrincipal claimsPrincipal) + { + return await this._userManager.GetUserAsync(claimsPrincipal); + } + public async Task AddAsync(User user, string password) { user.PasswordHash = this._userManager.PasswordHasher.HashPassword(user, password); @@ -45,6 +51,13 @@ namespace ExamTemplate.Data.Repositories return succeeded; } + public async Task EditUserAsync(User user) + { + IdentityResult result = await this._userManager.UpdateAsync(user); + + return result.Succeeded; + } + public async Task VerifyPasswordAsync(User user, string password) { return await this._userManager.CheckPasswordAsync(user, password); -- cgit v1.2.3