public async Task<ActionResult> Validate(ValidateTotpViewModel model) { if (this.ModelState.IsValid) { var user = await this.UserManager.FindByIdAsync(this.User.Identity.GetUserId()); model.IsTotpEnabled = user.IsTotpEnabled(); var totp = new Totp(user.TotpSecretKey); long timeStep; model.CodeIsValid = totp.VerifyTotp(model.Code, out timeStep, new VerificationWindow(2, 2)); model.TimeStepMatched = timeStep; } return this.View(model); }
public async Task<ActionResult> Validate() { var user = await this.UserManager.FindByIdAsync(this.User.Identity.GetUserId()); var model = new ValidateTotpViewModel { IsTotpEnabled = user.IsTotpEnabled() }; return this.View(model); }