public IActionResult Login(string username, string password) { LoginServices lgs = new LoginServices(_config); var user = lgs.AuthenticateUser(username, password); if (user == null) { return(Ok(new ResponseResult(500, StatusMessage.Error.ToString(), "Not Found"))); } var tokenString = lgs.GenerateJSONWebToken(user); IActionResult response = Ok(new ResponseResult(200, StatusMessage.Completed.ToString(), tokenString, user)); return(response); }
public ActionResult Autherize(string Username, string Password) { UserLogin user = new UserLogin(); user.UserName = Username; user.Password = Password; string sessionId = ""; Employee emp = LoginServices.AuthenticateUser(user); if (emp != null) { sessionId = LoginServices.CreateSessionForUser(emp); Session["SessionId"] = sessionId; // for double protection Session["USER"] = emp; //just using this thing for basic implementation return(RedirectToAction("RouteUser", new { sessionId })); } user.LoginErrorMessage = "Login Failed --- invalid Credentials"; return(RedirectToAction("index", user)); }
/// <summary> /// Authenticates the user. /// </summary> ///<param name="username">Username</param> ///<param name="password">Password</param> /// <returns>bool</returns> public override bool ValidateUser(string username, string password) { LoginServices oLoginServices = new LoginServices(); oLoginServices.sUserName = username; oLoginServices.sPassword = password; oLoginServices.DBConnectionString = ApplicationKeys.TakamulConnectionString; User user = oLoginServices.AuthenticateUser(); // Check if this is a valid user. if (user != null) { // Store the user temporarily in the context for this request. HttpContext.Current.Items.Add("User", user); return(true); } else { return(false); } }