예제 #1
0
        public ActionResult LogIn(LoginModel model, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                if (_accountRegistrationService.ValidateAccount(model.Email, model.Password))
                {
                    var account = _accountService.GetAccountByEmail(model.Email);

                    //sign in new account
                    _authenticationService.SignIn(account, model.RememberMe);

                    if (!String.IsNullOrEmpty(returnUrl) && Url.IsLocalUrl(returnUrl))
                        return Redirect(returnUrl);
                    else
                    {
                        if (account.IsAdmin())
                            return Redirect("~/Admin");
                        if (account.IsRegistered())
                            return RedirectToAction("Index", "Home");
                    }
                }
            }

            return View(model);
        }
예제 #2
0
 public ActionResult LogIn()
 {
     var account = _authenticationService.GetAuthenticatedAccount();
     if (account != null)
     {
         if (account.IsAdmin())
             return Redirect("~/Admin");
         if (account.IsRegistered())
             return RedirectToAction("Index", "Home");
     }
     var model = new LoginModel();
     model.RememberMe = true;
     return View(model);
 }