public ActionResult Index()
        {
            _siteConfiguration.UpdateSecureMode(Request);

            if (Request.IsAuthenticated)
            {
                var user = _userProvider.GetUserFromSelector(Request, _siteConfiguration);
                var loggedInViewModel = Mapper.Map<UserViewModel>(user);

                loggedInViewModel.SecureMode = _siteConfiguration.SecureMode;

                return RedirectToAction("Manage", new { email = user.EmailAddress });

            }

            var viewModel = new LoginViewModel() { SecureMode = _siteConfiguration.SecureMode };

            return View("Index", viewModel);
        }
        public ActionResult Login(LoginViewModel model)
        {
            _siteConfiguration.UpdateSecureMode(Request);
            model.SecureMode = _siteConfiguration.SecureMode;

            if (!ModelState.IsValid)
            {
                return View("Index", model);
            }

            var loginResult = _userProvider.AuthenticateUser(model.Email, model.Password, Response, true);

            if (loginResult.Authenticated)
            {
                return RedirectToAction("Manage", new { email = loginResult.UserPrincipal.EmailAddress });
            }

            ModelState.AddModelError("", loginResult.ErrorText);
            return View("Index", model);
        }
예제 #3
0
        public ActionResult Login(LoginViewModel postModel)
        {
            if (ModelState.IsValid)
            {
                if (authenticationService.IsPasswordCorrectForUser(postModel.Username, postModel.Password))
                {
                    SetAuthenticated(postModel.Username);

                    return RedirectToAction("Manage");
                }
                else
                {
                    return View(new LoginViewModel() { Username = postModel.Username, ErrorText = "Username or password is incorrect."});
                }
            }
            else
            {
                return View(new LoginViewModel() { Username = postModel.Username, ErrorText = "Some fields are invalid:" });
            }
        }