Beispiel #1
0
        public bool Authenticate(string userName, string password)
        {
            if (!userRepo.UsernameExists(userName))
            {
                return(false);
            }
            var user         = userRepo.GetByUserName(userName);
            var passwordHash = crypto.GetPasswordHash(password, user.PasswordSalt);

            return(passwordHash.Equals(user.PasswordHash));
        }
        public bool Authenticate(string userName, string password)
        {
            var user         = _userRepository.GetByUserName(userName);
            var passwordHash = _cryptographer.GetPasswordHash(password, user.PasswordSalt);

            return(passwordHash.Equals(user.PasswordHash));
        }
Beispiel #3
0
        public Account Register(RegisterRepresentation newRegistration)
        {
            newRegistration.Password = _cryptographer.GetPasswordHash(
                newRegistration.Password,
                _cryptographer.CreateSalt());
            var newAccount = _registrationMapper.Map(newRegistration);

            if (newAccount.Provider == "OAuth")
            {
                newAccount.ConfirmEmail(DateTime.Now);
            }

            return(newAccount);
        }
Beispiel #4
0
        public object Execute(UpdateUserCommandMessage commandMessage)
        {
            var user = _repository.GetById(commandMessage.Id) ?? new User();

            user.Name         = commandMessage.Name;
            user.EmailAddress = commandMessage.EmailAddress;
            user.PasswordSalt = _cryptographer.CreateSalt();
            user.PasswordHash = _cryptographer.GetPasswordHash(commandMessage.Password,
                                                               user.PasswordSalt);
            user.Username = commandMessage.Username;

            _repository.Save(user);

            return(user);           // new ReturnValue { Type = typeof(User), Value = user };
        }
        public bool PasswordMatches(User user, string password)
        {
            var passwordHash = _cryptographer.GetPasswordHash(password, user.PasswordSalt);

            return(passwordHash.Equals(user.PasswordHash));
        }