public bool Login(string login, string password)
        {
            // validate password
            var hashToCheck = CommonHelperAppService.HashPassword(password);

            return(CommonHelperAppService.ValidatePassword(password, hashToCheck));
        }
Пример #2
0
        public bool PasswordReset(string emailAddress)
        {
            // get user based upon email address
            var user = _unitOfWork.UserRepository.Get(u => u.Email == emailAddress).FirstOrDefault();

            if (user != null)
            {
                // for use below with unhashed password
                var userDto = Mapper.Map <UserDto>(user);

                // generate new password from Random
                userDto.Password = CommonHelperAppService.RandomString(8);

                // Hash it. Hash it, real good!
                user.Password = CommonHelperAppService.HashPassword(userDto.Password);

                _unitOfWork.UserRepository.Update(user);
                _unitOfWork.Save();

                MailerService.SendPasswordResetEmail(userDto);

                return(true);
            }

            return(false);
        }
        // Private Methods
        private static string HashPassword(string password)
        {
            var saltedHash = CommonHelperAppService.HashPassword(password);

            return(saltedHash);
        }