identity: add support for disabling 2fa

This commit is contained in:
Abdullah Atta
2026-04-17 11:28:33 +05:00
parent 33413b0a5c
commit ebb1d44edd
3 changed files with 12 additions and 10 deletions
@@ -79,9 +79,12 @@ namespace Streetwriters.Identity.Controllers
}
[HttpDelete]
public IActionResult Disable2FA()
public async Task<IActionResult> Disable2FA()
{
return BadRequest("2FA is mandatory and cannot be disabled.");
var user = await UserManager.GetUserAsync(User) ?? throw new Exception("User not found.");
if (!await UserManager.GetTwoFactorEnabledAsync(user)) return Ok();
await MFAService.DisableMFAAsync(user);
return Ok();
}
[HttpGet("codes")]