aboutsummaryrefslogtreecommitdiff
path: root/ExamTemplate/Data/Repositories/UserRepository.cs
diff options
context:
space:
mode:
Diffstat (limited to 'ExamTemplate/Data/Repositories/UserRepository.cs')
-rw-r--r--ExamTemplate/Data/Repositories/UserRepository.cs13
1 files changed, 13 insertions, 0 deletions
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<User> GetByClaimsAsync(ClaimsPrincipal claimsPrincipal)
+ {
+ return await this._userManager.GetUserAsync(claimsPrincipal);
+ }
+
public async Task<bool> 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<bool> EditUserAsync(User user)
+ {
+ IdentityResult result = await this._userManager.UpdateAsync(user);
+
+ return result.Succeeded;
+ }
+
public async Task<bool> VerifyPasswordAsync(User user, string password)
{
return await this._userManager.CheckPasswordAsync(user, password);