コード例 #1
0
ファイル: AccountController.cs プロジェクト: huntipl/MVC
        public ActionResult Login(LoginModel model, string returnUrl)
        {
            if (ModelState.IsValid && WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe))
            {
                return RedirectToLocal(returnUrl);
            }

            // If we got this far, something failed, redisplay form
            ModelState.AddModelError("", "The user name or password provided is incorrect.");
            return View(model);
        }
コード例 #2
0
        public ActionResult Login(LoginModel model, string returnUrl)
        {
            if (ModelState.IsValid && WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe))
            {
                return RedirectToLocal(returnUrl);
            }

            // Появление этого сообщения означает наличие ошибки; повторное отображение формы
            ModelState.AddModelError("", "Имя пользователя или пароль указаны неверно.");
            return View(model);
        }
コード例 #3
0
        public ActionResult Login(LoginModel model, string returnUrl)
        {
            if (ModelState.IsValid && WebSecurity.Login(model.Email, model.Password, persistCookie: model.RememberMe))
            {
                if (returnUrl != null)
                    return RedirectToLocal(returnUrl);

                if (Roles.IsUserInRole(model.Email, "User"))
                {
                    return RedirectToAction("Index", "Profile");
                }

                if (Roles.IsUserInRole(model.Email, "Company"))
                {
                    return RedirectToAction("Index", "Company");
                }
            }

            if (WebSecurity.UserExists(model.Email))
            {
                if (!WebSecurity.IsConfirmed(model.Email))
                {
                    return RedirectToAction("Resend", "Account", new { invalid = "1" });
                }
            }

            // If we got this far, something failed, redisplay form
            ModelState.AddModelError("", "The user name or password provided is incorrect.");
            return View(model);
        }