Exemplo n.º 1
0
        public ActionResult Login(LoginModel model, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                model.UserName = model.UserName.Trim();

                DataResult<User> validUser = userRegistrationService.ValidateUser(model.UserName, model.Password);

                if (validUser.Success)
                {
                    authenticationService.SignIn(validUser.Data, model.RememberMe);

                    // user is valid, redirect to the default page or requested page
                    if (!String.IsNullOrEmpty(returnUrl) && Url.IsLocalUrl(returnUrl))
                        return Redirect(returnUrl);
                    else
                        return RedirectToRoute(SystemRouteNames.HomePage);
                }
                else
                    ErrorNotification(validUser.ErrorMessages);
            }

            //If we got this far, something failed, redisplay form
            return View(model);
        }
Exemplo n.º 2
0
        public ActionResult Login()
        {
            // if the user is coming on the login page again, and session exists, redirect the user to the home page
            if (workContext.IsAuthenticated)
                return RedirectToRoute(SystemRouteNames.HomePage);

            var model = new LoginModel();

            return View(model);
        }