Login logging

This commit is contained in:
2014-06-18 23:06:19 -04:00
parent ea4351d6a8
commit e8614d76bd
+11 -10
View File
@@ -12,6 +12,7 @@ namespace MileageTraker.Web.Controllers
public class AccountController : ControllerBase
{
[AllowAnonymous]
[ActionLog]
public ActionResult Login(string returnUrl, string username)
{
if (User.Identity.IsAuthenticated)
@@ -25,6 +26,7 @@ namespace MileageTraker.Web.Controllers
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
[ActionLog]
public ActionResult Login(LoginViewModel model, string returnUrl)
{
if (ModelState.IsValid)
@@ -42,22 +44,21 @@ namespace MileageTraker.Web.Controllers
}
catch (UserAccountDisabledException)
{
ModelState.AddModelError("", "Account is disabled for " + model.Username + ".");
var errorMessage = "Account is disabled for " + model.Username + ".";
log4net.LogManager.GetLogger("AccountController.Login").InfoFormat(errorMessage);
ModelState.AddModelError("", errorMessage);
}
catch (UserLockedOutException)
{
ModelState.AddModelError("",
"Too many failed password attempts for " +
model.Username + ". Account is locked. " +
@"Use 'Forgot Password' or contact " +
"administrator to unlock.");
var errorMessage = "Too many failed password attempts for " + model.Username + ". Account is locked. " + @"Use 'Forgot Password' or contact " + "administrator to unlock.";
log4net.LogManager.GetLogger("AccountController.Login").InfoFormat(errorMessage);
ModelState.AddModelError("", errorMessage);
}
catch (UninitializedAccountException)
{
ModelState.AddModelError("",
"Account for " +
model.Username + " has not been initialized. " +
@"Please check your email for initialization instructions.");
var errorMessage = "Account for " + model.Username + " has not been initialized. " + @"Please check your email for initialization instructions.";
log4net.LogManager.GetLogger("AccountController.Login").InfoFormat(errorMessage);
ModelState.AddModelError("", errorMessage);
}
}