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)); }
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)); }
public async Task <OperationResult> UpdateGoogleAuthenticatorInfo([FromBody] GoogleAuthInfoModel requestModel) { return(await _authService.UpdateGoogleAuthenticatorInfo(requestModel)); }