コード例 #1
0
        public async Task <OperationResult> UpdateGoogleAuthenticatorInfo(GoogleAuthInfoModel requestModel)
        {
            try
            {
                var user = await _userService.GetCurrentUserAsync();

                if (user != null)
                {
                    user.TwoFactorEnabled = requestModel.IsTwoFactorEnabled;
                    var updateResult = _userManager.UpdateAsync(user).Result;
                    if (updateResult.Succeeded)
                    {
                        return(new OperationResult(true));
                    }
                }
            }
            catch (Exception)
            {
                return(new OperationResult(false));
            }

            return(new OperationResult(false));
        }
コード例 #2
0
        public async Task <OperationDataResult <GoogleAuthInfoModel> > GetGoogleAuthenticatorInfo()
        {
            try
            {
                var user = await _userService.GetCurrentUserAsync();

                if (user != null)
                {
                    var model = new GoogleAuthInfoModel()
                    {
                        PSK = user.GoogleAuthenticatorSecretKey,
                        IsTwoFactorEnabled = user.TwoFactorEnabled,
                        IsTwoFactorForced  = _appSettings.Value.IsTwoFactorForced
                    };
                    return(new OperationDataResult <GoogleAuthInfoModel>(true, model));
                }
            }
            catch (Exception)
            {
                return(new OperationDataResult <GoogleAuthInfoModel>(false));
            }

            return(new OperationDataResult <GoogleAuthInfoModel>(false));
        }
コード例 #3
0
 public async Task <OperationResult> UpdateGoogleAuthenticatorInfo([FromBody] GoogleAuthInfoModel requestModel)
 {
     return(await _authService.UpdateGoogleAuthenticatorInfo(requestModel));
 }