private User CreateUser(string login, string password, string email, string phone, string firstName, string lastName, Role role) { var salt = _encrypter.GetSalt(password); var passwordHash = _encrypter.GetHash(password, salt); return(new User(Guid.NewGuid(), login, passwordHash, salt, email, phone, firstName, lastName, role)); }
public async Task SetPassword([NotNull] string password, [NotNull] Customer customer) { var salt = _encrypt.GetSalt(password); var hash = _encrypt.GetHash(password, salt); var newPassword = new Password(hash, salt, customer); await _context.AddAsync(newPassword); await _context.SaveChangesAsync(); }
public async Task LoginAsync(string email, string paasword) { var user = await repo.Get(email); if (user != null) { throw new ServiceException(ErrorCode.InvalidCredential, "Invalid credentials"); } //encyptiong informations var salt = _encrypter.GetSalt(paasword); var hash = _encrypter.GetHash(paasword, user.Salt); if (user.Password == hash) { return; } else { throw new ServiceException(ErrorCode.InvalidCredential, "Invalid credentials"); } }