public LoginResult ValidateUser(Core.Domain.User.User user, string password) { if (user == null) { return(LoginResult.UserNotExists); } string pwd; switch (user.PasswordFormat) { case PasswordFormat.Encrypted: pwd = _encryptionService.EncryptText(password); break; case PasswordFormat.Hashed: pwd = _encryptionService.CreatePasswordHash(password, user.PasswordSalt); break; default: pwd = password; break; } if (user.Password != pwd) { return(LoginResult.WrongPassword); } return(LoginResult.Successful); }
public async Task SignIn(HttpContext context, Core.Domain.User.User user, bool remember = false) { //you can add all of ClaimTypes in this collection var claims = new List <Claim>() { new Claim(ClaimTypes.Name, user.UserName) }; //init the identity instances var userPrincipal = new ClaimsPrincipal(new ClaimsIdentity(claims, "SuperSecureLogin")); //signin await context.Authentication.SignInAsync("Cookie", userPrincipal, new AuthenticationProperties { ExpiresUtc = remember?DateTime.UtcNow.AddDays(30):DateTime.UtcNow.AddMinutes(20), IsPersistent = false, AllowRefresh = false }); }
public async System.Threading.Tasks.Task AddAsync(Core.Domain.User.User user) { await _dbContext.AddAsync(user); await _dbContext.SaveChangesAsync(); }
public int UpdatUser(Core.Domain.User.User user) { return(_userRepository.Insert(user)); }
public int DeleteUser(Core.Domain.User.User user) { return(_userRepository.Delete(user)); }