Methodize status message handling
This commit is contained in:
@@ -37,7 +37,7 @@ namespace MileageTraker.Web.Controllers
|
||||
if (success)
|
||||
{
|
||||
FormsAuthentication.SetAuthCookie(model.Username, model.RememberMe);
|
||||
TempData["StatusMessage"] = "Logged in as " + model.Username;
|
||||
SetStatusMessage("Logged in as " + model.Username);
|
||||
return RedirectToLocal(returnUrl);
|
||||
}
|
||||
ModelState.AddModelError("", "The user name or password provided is incorrect.");
|
||||
@@ -70,7 +70,7 @@ namespace MileageTraker.Web.Controllers
|
||||
[ValidateAntiForgeryToken]
|
||||
public ActionResult LogOff()
|
||||
{
|
||||
TempData["StatusMessage"] = User.Identity.Name + " logged off";
|
||||
SetStatusMessage(User.Identity.Name + " logged off");
|
||||
|
||||
FormsAuthentication.SignOut();
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace MileageTraker.Web.Controllers
|
||||
|
||||
if (changePasswordSucceeded)
|
||||
{
|
||||
TempData["StatusMessage"] = "Your password has been changed.";
|
||||
SetStatusMessage("Your password has been changed.");
|
||||
return RedirectToAction("Manage");
|
||||
}
|
||||
ModelState.AddModelError("", "The current password is incorrect or the new password is invalid.");
|
||||
@@ -169,18 +169,16 @@ namespace MileageTraker.Web.Controllers
|
||||
var email = new EmailNotificationService();
|
||||
var resetPasswordUrl = ResetPassword(user);
|
||||
email.SendResetPassword(user, resetPasswordUrl);
|
||||
TempData["StatusMessage"] = "Please check your email - we have sent a request for you to reset the password.";
|
||||
SetStatusMessage("Please check your email - we have sent a request for you to reset the password.");
|
||||
}
|
||||
else if (user == null)
|
||||
{
|
||||
TempData["StatusMessage"] = "Could not find username " + viewModel.Username + ".";
|
||||
TempData["StatusMessage-Type"] = "alert-error";
|
||||
SetStatusMessage("Could not find username " + viewModel.Username + ".", StatusType.Error);
|
||||
return RedirectToAction("ResetPassword");
|
||||
}
|
||||
else if (!user.IsApproved)
|
||||
{
|
||||
TempData["StatusMessage"] = "Account is disabled for " + viewModel.Username + ".";
|
||||
TempData["StatusMessage-Type"] = "alert-error";
|
||||
SetStatusMessage("Account is disabled for " + viewModel.Username + ".", StatusType.Error);
|
||||
}
|
||||
|
||||
// even when if not successful, let the user think they're getting a cookie
|
||||
@@ -232,7 +230,7 @@ namespace MileageTraker.Web.Controllers
|
||||
if (success)
|
||||
{
|
||||
FormsAuthentication.SetAuthCookie(viewModel.Username, false);
|
||||
TempData["StatusMessage"] = "Password set for " + viewModel.Username + ", logged in";
|
||||
SetStatusMessage("Password set for " + viewModel.Username + ", logged in");
|
||||
return RedirectToAction("Index", "CreateLog");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user