public IActionResult Login([FromBody] LoginViewModel auth) { IActionResult response; var result = new ResultViewModel(); result = _login.Authenticate(auth); if (!result.IsError) { var model = _login.ManageClaimsIdentity(auth); string token = _login.BuildToken(); var responseMessage = new { Employee = model, Token = token }; _login.SetupCookie(HttpContext, token); response = Ok(responseMessage); } else { response = Unauthorized(result); } return(response); }
public void Authenticate(string username, string password) { try { var response = _login.Authenticate(new Authorization.Bll.Models.LoginViewModel { Username = username, Password = password }); Console.WriteLine(response); } catch (Exception ex) { Assert.True(false, ex.Message); } }
public void TestConfigurationDenpendency() { try { var data = _login.Authenticate(new Bll.Models.LoginViewModel { Username = "******", Password = "******" }, new Bll.Models.EmployeeViewModel()); Assert.True(data, "Unauthorized"); } catch (Exception ex) { Assert.True(false, ex.Message); } }
public IActionResult Login([FromBody] LoginViewModel auth) { IActionResult response = Unauthorized(); var model = new EmployeeViewModel(); if (_login.Authenticate(auth, model)) { string token = _login.BuildToken(); var responseMessage = new { Employee = model, Token = token, RefreshToken = _refreshToken.GenerateRefreshToken(auth.Username) }; _login.SetupCookie(HttpContext, token); response = Ok(responseMessage); } return(response); }
public IActionResult Login([FromBody] LoginRequestDTO userRequest) { var response = _loginBll.Authenticate(userRequest.Login, userRequest.Password); return(Ok(response)); }