Login logging
This commit is contained in:
@@ -12,6 +12,7 @@ namespace MileageTraker.Web.Controllers
|
|||||||
public class AccountController : ControllerBase
|
public class AccountController : ControllerBase
|
||||||
{
|
{
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
|
[ActionLog]
|
||||||
public ActionResult Login(string returnUrl, string username)
|
public ActionResult Login(string returnUrl, string username)
|
||||||
{
|
{
|
||||||
if (User.Identity.IsAuthenticated)
|
if (User.Identity.IsAuthenticated)
|
||||||
@@ -25,6 +26,7 @@ namespace MileageTraker.Web.Controllers
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[ValidateAntiForgeryToken]
|
[ValidateAntiForgeryToken]
|
||||||
|
[ActionLog]
|
||||||
public ActionResult Login(LoginViewModel model, string returnUrl)
|
public ActionResult Login(LoginViewModel model, string returnUrl)
|
||||||
{
|
{
|
||||||
if (ModelState.IsValid)
|
if (ModelState.IsValid)
|
||||||
@@ -42,22 +44,21 @@ namespace MileageTraker.Web.Controllers
|
|||||||
}
|
}
|
||||||
catch (UserAccountDisabledException)
|
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)
|
catch (UserLockedOutException)
|
||||||
{
|
{
|
||||||
ModelState.AddModelError("",
|
var errorMessage = "Too many failed password attempts for " + model.Username + ". Account is locked. " + @"Use 'Forgot Password' or contact " + "administrator to unlock.";
|
||||||
"Too many failed password attempts for " +
|
log4net.LogManager.GetLogger("AccountController.Login").InfoFormat(errorMessage);
|
||||||
model.Username + ". Account is locked. " +
|
ModelState.AddModelError("", errorMessage);
|
||||||
@"Use 'Forgot Password' or contact " +
|
|
||||||
"administrator to unlock.");
|
|
||||||
}
|
}
|
||||||
catch (UninitializedAccountException)
|
catch (UninitializedAccountException)
|
||||||
{
|
{
|
||||||
ModelState.AddModelError("",
|
var errorMessage = "Account for " + model.Username + " has not been initialized. " + @"Please check your email for initialization instructions.";
|
||||||
"Account for " +
|
log4net.LogManager.GetLogger("AccountController.Login").InfoFormat(errorMessage);
|
||||||
model.Username + " has not been initialized. " +
|
ModelState.AddModelError("", errorMessage);
|
||||||
@"Please check your email for initialization instructions.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user