Ejemplo n.º 1
0
 public User(Guid id,
             string email,
             string username,
             string password)
 {
     this.Id       = id;
     this.Email    = email;
     this.Username = username;
     this.Password = PasswordHashProvider.ComputeHash(password);
 }
Ejemplo n.º 2
0
        protected override async Task Handle(SignInCommand request, CancellationToken cancellationToken)
        {
            var user = await _repository.FindSingleAsync((u) => u.Username == request.Username);

            if (user == null)
            {
                throw new ValidationException("Unknown user");
            }

            var hashedPassword = PasswordHashProvider.ComputeHash(request.Password);

            if (hashedPassword != user.Password)
            {
                throw new ValidationException("Invalid password");
            }

            await _accountService.SignIn(user.Id, user.Username, user.Email);
        }