Example #1
0
        //public AuthService(IUnitOfWork unitOfWork)
        //{
        //    this._unitOfWork = unitOfWork;
        //}

        public LogInStatus SignIn(LoginViewModel loginModel, bool rememberMe)
        {
            //User userDetail = _userRepository.GetUserWithUserName(loginModel.UserName);
            UserAuthViewModel userDetail = _userRepository.GetUserDetailsByUserName(loginModel.UserName);
            LogInStatus       result     = LogInStatus.Failure;

            if (userDetail != null)
            {
                if (PasswordHelpers.ValidateUser(userDetail.PasswordFormat, loginModel.Password, userDetail.Password, userDetail.PasswordSalt))
                {
                    string token = TokenManager.GenerateToken(userDetail, 30);
                    userDetail.Token = token;
                    SignInSucessfully(userDetail, rememberMe, loginModel.IpAddress);
                    result = LogInStatus.Success;
                }
                else
                {
                    result = LogInStatus.Failure;
                }
            }
            return(result);
        }