summaryrefslogtreecommitdiff
path: root/Project-Unite/Controllers
diff options
context:
space:
mode:
authorMichael <[email protected]>2017-04-17 21:01:59 -0400
committerMichael <[email protected]>2017-04-17 21:01:59 -0400
commit2d5f268549575a0b0d9be358fe6e2b80794a7f90 (patch)
treea3c8727466fba42d50abccb3be155abc11bcc5de /Project-Unite/Controllers
parent662bffcdf0cfc02ef8c85d55170243a44beee22b (diff)
downloadproject-unite-2d5f268549575a0b0d9be358fe6e2b80794a7f90.tar.gz
project-unite-2d5f268549575a0b0d9be358fe6e2b80794a7f90.tar.bz2
project-unite-2d5f268549575a0b0d9be358fe6e2b80794a7f90.zip
fix login password check bug
Diffstat (limited to 'Project-Unite/Controllers')
-rw-r--r--Project-Unite/Controllers/AccountController.cs41
1 files changed, 24 insertions, 17 deletions
diff --git a/Project-Unite/Controllers/AccountController.cs b/Project-Unite/Controllers/AccountController.cs
index 729bcec..2251fc0 100644
--- a/Project-Unite/Controllers/AccountController.cs
+++ b/Project-Unite/Controllers/AccountController.cs
@@ -95,26 +95,33 @@ The address used to send this message is not a no-reply address. In fact, my nam
[ValidateAntiForgeryToken]
public async Task<ActionResult> Login(LoginViewModel model, string returnUrl)
{
- if (!ModelState.IsValid)
+ try
{
- return View(model);
- }
+ if (!ModelState.IsValid)
+ {
+ return View(model);
+ }
- // This doesn't count login failures towards account lockout
- // To enable password failures to trigger account lockout, change to shouldLockout: true
- var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout: false);
- switch (result)
+ // This doesn't count login failures towards account lockout
+ // To enable password failures to trigger account lockout, change to shouldLockout: true
+ var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout: false);
+ switch (result)
+ {
+ case SignInStatus.Success:
+ return RedirectToLocal(returnUrl);
+ case SignInStatus.LockedOut:
+ return View("Lockout");
+ case SignInStatus.RequiresVerification:
+ return RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe });
+ case SignInStatus.Failure:
+ default:
+ ModelState.AddModelError("", "Invalid login attempt.");
+ return View(model);
+ }
+ }
+ catch
{
- case SignInStatus.Success:
- return RedirectToLocal(returnUrl);
- case SignInStatus.LockedOut:
- return View("Lockout");
- case SignInStatus.RequiresVerification:
- return RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe });
- case SignInStatus.Failure:
- default:
- ModelState.AddModelError("", "Invalid login attempt.");
- return View(model);
+ ModelState.AddModelError("Password", new Exception("An error occurred while verifying your password. Possible cause: If you are a user from before the website was revamped, you don't have a usable password. Please reset it, otherwise you won't be able to log in."));
}
}