public void AuditSuccess_IsNotLogged() { using (IScarfContext context = ScarfLogging.BeginInlineContext()) { var attribute = new LogAuditAttribute(MessageType.AuditLogin); BeforeAction(attribute); ScarfAudit.LoggedInAs("Test"); AfterAction(attribute); } Assert.AreEqual(0, dataSource.Messages.Count); }
public void LoginAudit() { using (IScarfContext context = ScarfLogging.BeginInlineContext()) { ScarfAudit.Start(MessageType.AuditLogin); ScarfAudit.LoggedInAs("Test"); context.Commit(); } ScarfLogMessage msg = dataSource.Messages.Single(); Assert.AreEqual(MessageClass.Audit, msg.MessageClass); Assert.AreEqual(MessageType.AuditLogin, msg.MessageType); Assert.AreEqual(true, msg.Success.Value); }
public async Task <ActionResult> Login(LoginViewModel model, string returnUrl) { if (ModelState.IsValid) { var user = await UserManager.FindAsync(model.UserName, model.Password); if (user != null) { await SignInAsync(user, model.RememberMe); ScarfAudit.LoggedInAs(user.UserName); return(RedirectToLocal(returnUrl)); } else { ModelState.AddModelError("", "Invalid username or password."); } } // If we got this far, something failed, redisplay form ScarfAudit.Failed(); return(View(model)); }