コード例 #1
0
 public ActionResult Login(LoginViewModel model, string returnUrl)
 {
     if (ModelState.IsValid)
     {
         if (authProvider.Authenticate(model.UserName, model.Password))
         {
             return Redirect(returnUrl ?? Url.Action("Index", "Admin"));
         }
         else
         {
             ModelState.AddModelError("", "Incorrect username or password");
             return View();
         }
     }
     else
     {
         return View();
     }
 }
コード例 #2
0
        public ActionResult Login(LoginViewModel model, string returnUrl)
        {
            if (ModelState.IsValid) {

                var user = userRepository.GetUser(model.UserName, SHA1Encoding.Encode(model.Password));

                if (user != null)
                {
                    FormsAuthentication.SetAuthCookie(user.Email, false);
                    return Redirect(returnUrl ?? Url.Action("Index", "Admin"));
                }
                else {
                    ModelState.AddModelError("", "Incorrect username or password");
                    return View();
                }
            }
            else {
                return View();
            }
        }
コード例 #3
0
 public ActionResult Login(LoginViewModel model, string ReturnUrl)
 {
     if (ModelState.IsValid)
     {
         if (authentication.Authenticate(model.UserName, model.Password))
         {
             System.Web.Security.FormsAuthentication.SetAuthCookie(model.UserName, false);
             return Redirect(ReturnUrl ?? Url.Action("Index", "Admin"));
         }
         else
         {
             ModelState.AddModelError("", "Incorrect login info");
             return View();
         }
     }
     else
     {
         return View();
     }
 }