public async Task <ActionResult> Login(LoginModel model, string returnUrl) { if (User.Identity.IsAuthenticated) { return(RedirectToAction("Index", "Home")); } if (!ModelState.IsValid) { return(View(model)); } var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, isPersistent : false, shouldLockout : false); switch (result) { case SignInStatus.Success: { ApplicationUser user = AccountQueries.GetCurrentUser(model.Email); CultureSetAttribute.SavePreferredCulture(HttpContext.Response, user.PreferredCulture); if (Url.IsLocalUrl(returnUrl)) { return(Redirect(returnUrl)); } return(RedirectToAction("Login", "Account")); } case SignInStatus.Failure: default: { ModelState.AddModelError("", "Invalid login"); return(View(model)); } } }
public ActionResult UserPreferences(PreferencesModel model) { if (ModelState.IsValid) { string userName = User.Identity.Name; string prefferedCulture = model.cultures.Where(x => x.Id == model.CultureIdentifier).Select(x => x.CultureTag).SingleOrDefault(); AccountQueries.ChangeLanguagePreference(userName, prefferedCulture); CultureSetAttribute.SavePreferredCulture(HttpContext.Response, prefferedCulture); } return(View(model)); }
public ActionResult Language(string culture) { CultureSetAttribute.SavePreferredCulture(HttpContext.Response, culture); return(Redirect(Request.UrlReferrer.LocalPath)); }