public async Task <IActionResult> Verification([FromBody] VerifyVM vm) { var user = await _userManager.FindByEmailAsync(vm.Email); if (user == null) { return(BadRequest("Cannot find email")); } var result = await _userManager.ConfirmEmailAsync(user, vm.Token); if (result.Succeeded) { return(Ok("Verified")); } else { return(BadRequest("Email confirmation failed")); } }
public async Task <IActionResult> EnableAuthenticator([FromBody] VerifyVM model) { var user = await _userManager.GetUserAsync(User); var mfaEnabled = await _mfaService.IsMfaEnabledAsync(user); if (mfaEnabled) { return(new BadRequestObjectResult("2FA is already enabled")); } var outcome = await _mfaService.VerifyTokenAsync(user, model.TwoFactorCode); if (!outcome.IsSuccess) { return(new BadRequestObjectResult(outcome.Error)); } await _userManager.SetTwoFactorEnabledAsync(user, true); return(new OkObjectResult("2FA Enabled")); }