コード例 #1
0
        public AccountStatus CheckAccount(string email, string password)
        {
            var account = _accountRepo.GetByEmail(email);

            if (account == null)
            {
                _logger.LogInformation("No account with the email: " + email);
                return(AccountStatus.Unauthenticated);
            }

            var hashedPassword = PasswordHasher.HashPassword(password, account.PasswordSalt);

            return(hashedPassword.Item1 != account.PasswordHash ? AccountStatus.Unauthenticated : account.Status);
        }
コード例 #2
0
        public AccountModel SignUp(SignUpDto dto)
        {
            return(ProtectedExecute <SignUpDto, AccountModel>(accountDto =>
            {
                accountDto.Password = Hasher.GetHash(accountDto.Password);
                AccountModel model = Mapper.Map <SignUpDto, AccountModel>(accountDto);

                if (AccountRepo.GetByLogin(model.Login) != null)
                {
                    throw new ConflictException("Login");
                }

                if (AccountRepo.GetByEmail(model.Email) != null)
                {
                    throw new ConflictException("Email");
                }

                return AccountRepo.Create(model);
            }, dto));
        }