Пример #1
0
 public ActionResult SignIn(FormCollection Form)
 {
     //return View();
     UserModels usm = new UserModels();
     var lgd = usm.Authenticate(Form["username"], Form["password"]);
     if (lgd == null)
     {
         return RedirectToAction("Index", new { Error = "Wrong account or password" });
     }
     else {
         Session["UserName"] = ((LoginDetail)lgd).LOGIN_USERNAME;
         Session["SessionID"] = Session.SessionID;
         RoleModels rm = new RoleModels();
         RoleDetail rd = rm.FindOneByID(((LoginDetail)lgd).ROLE_ID);
         Session["Role"] = rd.ROLE_TITLE;
         Session["UserId"] = ((LoginDetail)lgd).LOGIN_ID;
         return RedirectToAction("Index", "Dashboard");
     }
 }
Пример #2
0
 public ActionResult Login(FormCollection collection)
 {
     UserModels usm = new UserModels();
     var lgd = usm.Authenticate(collection["Username"], collection["Password"]);
     if (lgd == null)
     {
         ViewData["Error"] = "* Wrong account or password";
         return View();
     }
     else
     {
         Session[Constants.USERNAME] = ((LoginDetail)lgd).LOGIN_USERNAME;
         Session[Constants.SESSIONID] = Session.SessionID;
         Session[Constants.ROLE] = (lgd.RoleDetail.ROLE_ID == 0) ? "User" : lgd.RoleDetail.ROLE_TITLE;
         Session[Constants.USERID] = ((LoginDetail)lgd).LOGIN_ID;
         return RedirectToAction("Index", "Welcome");
     }
 }