Exemple #1
0
 public IActionResult Login([Bind("Username, Password")] User user)
 {
     if (!DAL.TestConnection())
     {
         SessionVariables.SetErrorMessageStay("Unable to make a connection with the database. Please check with an administrator.");
         return(View());
     }
     if (ModelState.IsValid)
     {
         User currentUser = DAL.GetUser(user.Username, user.Password);
         if (currentUser != null)
         {
             SessionVariables.SetCurrentUserID(HttpContext, currentUser.ID);
             SessionVariables.SetSuccessMessage("Logged in");
             return(RedirectToAction("Index", "Section"));
         }
         SessionVariables.SetErrorMessage("Error logging in, Check username and password");
         user.Password = "";
         return(View(user));
     }
     return(View());
 }
Exemple #2
0
 public IActionResult Logout()
 {
     SessionVariables.SetCurrentUserID(HttpContext, -1);
     SessionVariables.LoggedIn = false;
     return(RedirectToAction("Login", "User"));
 }