public IActionResult Post(string username, string password) { var auth = new AuhtenticationManager(); if (auth.CheckUser(username, password)) { var token = AuhtenticationManager.GenerateToken(username, 30); return(Json(token)); } return(BadRequest("Wrong Username or Password")); }
public IActionResult Login(LoginViewModel model) { var auth = new AuhtenticationManager(); var result = auth.CheckUser(model.Username, model.Password); if (result) { var token = AuhtenticationManager.GenerateToken(model.Username, 30); HttpContext.Session.SetString(sessionKey, token.Token); return(RedirectToAction("Profile", "User")); } return(View(model)); }