コード例 #1
0
        public UserTwoFactorSettings GetMySettings()
        {
            var userDetails = CustomDatabase.GetUserDetails(Security.GetUserId());

            var viewModel = new UserTwoFactorSettings()
            {
                IsSetup = userDetails != null && userDetails.IsValidated
            };

            return(viewModel);
        }
コード例 #2
0
        public UserTwoFactorSettings RemoveTwoFactor()
        {
            var model   = new UserTwoFactorSettings();
            var userId  = Security.GetUserId();
            var details = CustomDatabase.GetUserDetails(userId);

            if (details == null || !details.IsValidated)
            {
                throw new UnauthorizedAccessException("This account hasnt got authenticator setup");
            }

            details.IsValidated = false;
            CustomDatabase.Update(details);

            return(model);
        }
コード例 #3
0
        public GoogleAuthenticatorSettingsModel RemoveGoogleAuthenticatorForUser(int id)
        {
            CheckAuth();
            var model = new UserTwoFactorSettings();

            var details = CustomDatabase.GetUserDetails(id);

            if (details == null || !details.IsValidated)
            {
                throw new UnauthorizedAccessException("This account hasnt got authenticator setup");
            }

            details.IsValidated = false;
            CustomDatabase.Update(details);


            return(GetGoogleAuthenticatorSettings());
        }