diff options
Diffstat (limited to 'ExamTemplate/Data/Repositories/UserRepository.cs')
| -rw-r--r-- | ExamTemplate/Data/Repositories/UserRepository.cs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/ExamTemplate/Data/Repositories/UserRepository.cs b/ExamTemplate/Data/Repositories/UserRepository.cs index 97eb21b..04e1f45 100644 --- a/ExamTemplate/Data/Repositories/UserRepository.cs +++ b/ExamTemplate/Data/Repositories/UserRepository.cs @@ -1,6 +1,7 @@ using System.Threading.Tasks; using ExamTemplate.Data.Models; using Microsoft.AspNetCore.Identity; +using Microsoft.EntityFrameworkCore; namespace ExamTemplate.Data.Repositories { @@ -17,6 +18,13 @@ namespace ExamTemplate.Data.Repositories this._roleManager = roleManager; } + public async Task<User> GetByUsernameAsync(string username) + { + return await this._userManager.Users + .Include(x => x.Roles) + .FirstOrDefaultAsync(x => x.UserName == username); + } + public async Task<bool> AddAsync(User user, string password) { user.PasswordHash = this._userManager.PasswordHasher.HashPassword(user, password); @@ -36,5 +44,10 @@ namespace ExamTemplate.Data.Repositories return succeeded; } + + public async Task<bool> VerifyPasswordAsync(User user, string password) + { + return await this._userManager.CheckPasswordAsync(user, password); + } } } |
