Beispiel #1
0
        public ActionResult Login(LoginViewModel model)
        {
            if (ModelState.IsValid)
            {
                using (SBSVEntities e = new SBSVEntities())
                {
                    Data.User user = e.Users.Where(s => s.Email == model.Email && s.Password == model.Password).Select(s => s).FirstOrDefault();
                    if (user == null)
                    {
                        ModelState.Clear();
                        ModelState.AddModelError("CustomError", "Password Combination Not Match");
                        return View();
                    }
                    else
                    {
                        FormsAuthentication.SetAuthCookie(model.Email, true);
                        if (!string.IsNullOrEmpty(model.ReturnUrl))
                        {
                            return Redirect(model.ReturnUrl);
                        }
                        return RedirectToAction("Index");
                    }
                }
            }


            return View();
        }
Beispiel #2
0
        public ActionResult Login(string ReturnUrl)
        {
            if(Request.IsAuthenticated)
                return RedirectToAction("Index");

            var model = new LoginViewModel();
            if (!string.IsNullOrEmpty(ReturnUrl))
            {
                model.ReturnUrl = ReturnUrl;
            }
            return View(model);
        }