public ActionResult Index(CredentialLoginBinder credential, string returnUrl) { if (!this.ModelState.IsValid) { IndexViewModel model = new IndexViewModel(); model.Credential = credential; return this.View(model); } bool validCredentials = Membership.ValidateUser(credential.Username, credential.Password); if (!validCredentials) { IndexViewModel model = new IndexViewModel(); model.Credential = credential; return this.View(model); } FormsAuthentication.SetAuthCookie(credential.Username, true); this.Logger.InfoFormat("User '{0}' is logged in.", credential.Username); if (!string.IsNullOrEmpty(returnUrl)) { return this.Redirect(returnUrl); } return this.urlBuilder.Admin.Home().Redirect(); }
public ActionResult Index(string returnUrl) { IndexViewModel model = new IndexViewModel(); model.Credential = new CredentialLoginBinder(); return this.View(model); }