public ActionResult Index(loginValidation V)
 {
     if (ModelState.IsValid)
     {
         string      user = Request.Form["Username"];
         string      pass = Request.Form["Password"];
         Login_Table L    = userBus.search(user, pass);
         if (L != null)
         {
             Session["user"] = L.User_ID;
             Session["type"] = L.UserType;
             if (L.UserType == "Admin")
             {
                 return(View("page1"));
             }
             else
             {
                 return(View("page2"));
             }
         }
         else
         {
             ViewBag.msg = "Invalid Credentails";
             return(View("Index"));
         }
     }
     return(View());
 }
Exemplo n.º 2
0
        public ActionResult Login(loginValidation model, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                string user     = model.UserName;
                string password = "******";
                if (string.IsNullOrEmpty(model.Password))
                {
                    ModelState.AddModelError("", "The user login or password provided is incorrect.");
                }

                if (model.Password == password && model.UserName == "test")
                {
                    // Request.Cookies["userid"].Value = user;

                    FormsAuthentication.SetAuthCookie(model.UserName, false);
                    if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") &&
                        !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
                    {
                        return(Redirect(returnUrl));
                    }
                    else
                    {
                        return(RedirectToAction("Index", "Home"));
                    }
                }
                else
                {
                    ModelState.AddModelError("", "The password provided is incorrect.");
                }
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Exemplo n.º 3
0
 public ActionResult Index()
 {
     if (User.Identity.IsAuthenticated)
     {
         return(View());
     }
     else
     {
         loginValidation obj = new loginValidation();;
         return(Login(obj));
     }
 }
Exemplo n.º 4
0
 public ActionResult search(loginValidation T)
 {
     if (ModelState.IsValid)
     {
         string user = Request.Form["username"];
         string pass = Request.Form["password"];
         bool   msg  = loginOps.search(user, pass);
         if (msg == true)
         {
             return(View());
         }
         else
         {
             return(View("loginPage"));
         }
     }
     return(View("loginPage"));
 }
Exemplo n.º 5
0
 public ActionResult Login(loginValidation obj)
 {
     return(View(obj));
 }