public ActionResult Login(LoginViewModel model) { if (model == null) { throw new ArgumentNullException("model"); } if (ModelState.IsValid) { var result = this._authenticationService.LogOn(model.Email, model.Password); if (result.Success) { var returnUrl = Web.Helpers.HtmlDecode(model.ReturnUrl, false); if (this.Url != null && Url.IsLocalUrl(returnUrl)) { return this.Redirect(returnUrl); } else { var redirectParams = StrixPlatform.Cultures.Count() > 1 ? new { area = string.Empty, language = result.PreferredCulture } : new { area = string.Empty, language = string.Empty }; return this.RedirectToAction(MvcConstants.INDEX, "Home", redirectParams); } } else { ModelState.AddModelError(string.Empty, Resources.Interface.LoginFailedContainer); ViewBag.LoginError = result.Message; } } // If we got this far, something failed, redisplay form return this.View(model); }
public ActionResult Login() { LoginViewModel model = new LoginViewModel(); model.ReturnUrl = Request.Params["returnUrl"]; return this.View(model); }