示例#1
0
        private AuthResponseModel AuthenticateUser(AuthRequestModel login)
        {
            AuthResponseModel user = null;
            var authBL             = new AuthBL();
            var authenticateResult = authBL.AuthenticateUser(login);

            if (!authenticateResult.Status)
            {
                return(user);
            }

            user = authenticateResult.Value;
            return(user);
        }
示例#2
0
 public IActionResult Login([FromForm] Login loginInput)
 {
     if (ModelState.IsValid)
     {
         Serilog.Log.Debug($"Login Attempt - Session: {HttpContext.Session.Id} - IP: {_accessor.HttpContext.Connection.RemoteIpAddress} - {loginInput}");
         LoginResponse loginResponse = AuthBL.AuthenticateUser(loginInput, _authRepository, _configuration);
         if (loginResponse.success)
         {
             Serilog.Log.Debug($"Login Success - Session: {HttpContext.Session.Id} - IP: {_accessor.HttpContext.Connection.RemoteIpAddress} - {loginInput}");
             HttpContext.Session.SetString("JWToken", loginResponse.token); //
             return(Redirect("~/"));
         }
         else
         {
             return(RedirectToAction("Login", "Auth", "Invalid"));
         }
     }
     else
     {
         return(BadRequest("Invalid Login Model"));
     }
 }