Esempio n. 1
0
        public IDataResult <UserAuth> Login(UserForLoginDto userForLoginDto)
        {
            var userToCheck = _userAuthService.GetByMail(userForLoginDto.Email);

            if (userToCheck == null)
            {
                return(new ErrorDataResult <UserAuth>(Messages.UserNotFound));
            }

            if (!HashingHelper.VerifyPasswordHash(userForLoginDto.Password, userToCheck.PasswordHash, userToCheck.PasswordSalt))
            {
                return(new ErrorDataResult <UserAuth>(Messages.PasswordError));
            }

            return(new SuccessDataResult <UserAuth>(userToCheck, Messages.SuccessfullLogin));
        }