public async Task <Result <AddTwoFactorAuthenticatorViewModel> > GetAuthenticatorViewModel() { Result <AppUserEntity> getAppUserResult = await GetAppUser(); if (getAppUserResult.Failure) { return(Result.Fail <AddTwoFactorAuthenticatorViewModel>(getAppUserResult.Errors)); } AppUserEntity appUser = getAppUserResult.Value; Result <(string sharedKey, string authenticatorUri)> result = await _twoFactorAuthService.Generate2faCode(appUser.Id); if (result.Failure) { return(Result.Fail <AddTwoFactorAuthenticatorViewModel>(result.Errors)); } (string sharedKey, string authenticatorUri) = result.Value; AddTwoFactorAuthenticatorViewModel model = new AddTwoFactorAuthenticatorViewModel( sharedKey: sharedKey, authenticationUri: authenticatorUri); return(Result.Ok(model)); }
public async Task <Result <AddTwoFactorAuthenticatorViewModel> > GetAddTwoFactorAuthenticatorViewModel(string userId, string sessionCode, string ip) { Result <(string sharedKey, string authenticatorUri)> result = await _twoFactorAuthService.Generate2faCode(userId, sessionCode, ip); if (result.Failure) { return(Result.Fail <AddTwoFactorAuthenticatorViewModel>(result.Errors)); } (string sharedKey, string authenticatorUri) = result.Value; AddTwoFactorAuthenticatorViewModel model = new AddTwoFactorAuthenticatorViewModel( sharedKey: sharedKey, authenticationUri: authenticatorUri); return(Result.Ok(model)); }