Created
March 13, 2017 19:24
-
-
Save patkleef/f7dbbb8363c6997e00490a158cdcdc48 to your computer and use it in GitHub Desktop.
Application Insights Blog - ApplicationInsightsEventTracking.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [HttpPost] | |
| [AllowAnonymous] | |
| [ValidateAntiForgeryToken] | |
| public async Task<ActionResult> Login(LoginViewModel model, string returnUrl) | |
| { | |
| 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) | |
| { | |
| 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: | |
| var dic = new Dictionary<string, string>(); | |
| dic.Add("email", model.Email); | |
| _telemetryClient.TrackEvent("InvalidLogin", dic); | |
| ModelState.AddModelError("", "Invalid login attempt."); | |
| return View(model); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment