예제 #1
0
 public ActionResult Login(string email, string password)
 {
     foreach (var user in db.Users.ToList())
     {
         if (user.Email == email && user.Password == password)
         {
             Auth.SetUserId(user.UserId);
             Auth.SetRole((int)Auth.Roles.LibraryUser);
             break;
         }
     }
     foreach (var user in db.Employees.ToList())
     {
         if (user.Email == email && user.Password == password)
         {
             Auth.SetRole((int)Auth.Roles.LibraryWorker);
             break;
         }
     }
     foreach (var user in db.Publishers.ToList())
     {
         if (user.Email == email && user.Password == password)
         {
             Auth.SetUserId(user.PublisherId);
             Auth.SetRole((int)Auth.Roles.Publisher);
             break;
         }
     }
     return(RedirectToAction("index", "Home"));
 }
예제 #2
0
 public ActionResult Logout()
 {
     Auth.SetRole((int)Auth.Roles.NotLoggedIn);
     Auth.SetUserId(0);
     return(RedirectToAction("Login"));
 }