private async Task CheckUserHas2faEnabled(AppUser user = null)
 {
     if (!await _manageAuthenticationService.CheckUserHas2faEnabled(User, user))
     {
         throw new InvalidOperationException($"Cannot generate recovery codes for user with ID '{User.GetUserId()}' because they do not have 2FA enabled.");
     }
 }
예제 #2
0
        public async Task <IActionResult> OnGet()
        {
            var has2faEnabled = await _manageAuthenticationService.CheckUserHas2faEnabled(User);

            if (!has2faEnabled)
            {
                throw new InvalidOperationException($"Cannot disable 2FA for user with username '{User.Identity.Name}' as it's not currently enabled.");
            }

            return(Page());
        }