コード例 #1
0
 public bool Authorize(LoginModel loginModel)
 {
     var user = UserServiceFactory.Create().GetById(loginModel.Email);
     if (user != null)
     {
         if (user.Confirm)
         {
             return user.Password == loginModel.Password;
         }
     }
     return false;
 }
コード例 #2
0
        public ActionResult Login(LoginModel loginModel, string ReturnUrl)
        {
            if (ModelState.IsValid)
            {
                var result = AuthenticationServiceFactory.Create().Authorize(loginModel);
                if (result)
                {
                    Authentication.SetAuthCookie(loginModel.Email, false);

                    if (ReturnUrl != null)
                    {
                        return Redirect(ReturnUrl);
                    }
                    return RedirectToAction("Index", "Home");
                }
            }
            ViewBag.error = "User Email or Password are incorrect";
            return View();
        }