コード例 #1
0
 public ActionResult CheckLogin(Login login)
 {
     ShopAcc.Models.ShopAccEntities1 db = new ShopAcc.Models.ShopAccEntities1();
     login          = new Login();
     login.email    = Request.Params["email"].ToString();
     login.password = Request.Params["password"].ToString();
     login.password = ShopAcc.Models.MaHoa.md5(login.password);
     ShopAcc.Models.THANHVIEN nv = new ShopAcc.Models.THANHVIEN();
     nv = (from p in db.THANHVIENs where p.EMAIL == login.email && p.PASSWORD == login.password select p).FirstOrDefault();
     if (nv != null)
     {
         Session["User"] = nv;
         FormsAuthentication.SetAuthCookie(nv.ID.ToString(), true);
         if (nv.QUYEN == null || nv.QUYEN == 0)
         {
             return(Redirect("/TrangChu"));
         }
         else
         {
             return(Redirect("/ShopAdministrator/Home"));
         }
     }
     return(View("Index"));
 }