Ejemplo n.º 1
0
        public virtual async Task <ActionResult> ChangeMultiFactorAuthentication(bool enableMultiFactor)
        {
            var user = GetCurrentUser();

            await UserService.ChangeMultiFactorAuthentication(user, enableMultiFactor);

            TempData["Message"] = string.Format(
                enableMultiFactor ? Strings.MultiFactorAuth_Enabled : Strings.MultiFactorAuth_Disabled,
                _config.Brand);

            if (enableMultiFactor)
            {
                // Add the claim to remove the warning indicators for 2FA.
                OwinContext.AddClaim(NuGetClaims.EnabledMultiFactorAuthentication);
            }
            else
            {
                // Remove the claim from login to show warning indicators for 2FA.
                OwinContext.RemoveClaim(NuGetClaims.EnabledMultiFactorAuthentication);
            }

            return(RedirectToAction(AccountAction));
        }