<commit_before>import { call, put, takeLatest, fork, all } from 'redux-saga/effects';
import { modules } from 'veritone-redux-common';
const { user: userModule } = modules;

import { REQUEST_OAUTH_GRANT, OAUTH_GRANT_FLOW_FAILED } from '../modules/oauth';
import { login } from '../../shared/VeritoneAuth';

function* requestOAuthGrant({ payload: { OAuthURI } }) {
  let token;

  try {
    let { OAuthToken } = yield call(login, OAuthURI);
    token = OAuthToken;
  } catch (e) {
    console.log('oauth flow error', e);
    yield put({ type: OAUTH_GRANT_FLOW_FAILED });
    return;
  }

  yield put(userModule.fetchUser({ token }));
}

function* watchOAuthGrantRequest() {
  yield takeLatest(REQUEST_OAUTH_GRANT, requestOAuthGrant);
}

export default function* root() {
  yield all([fork(watchOAuthGrantRequest)]);
}<commit_msg>put success event when oauth flow is finished<commit_after>import { call, put, takeLatest, fork, all } from 'redux-saga/effects';
import { modules } from 'veritone-redux-common';
const { user: userModule } = modules;

import {
  REQUEST_OAUTH_GRANT,
  OAUTH_GRANT_FLOW_FAILED,
  OAuthGrantSuccess
} from '../modules/oauth';
import { login } from '../../shared/VeritoneAuth';

function* requestOAuthGrant({ payload: { OAuthURI } }) {
  let token;

  try {
    let { OAuthToken } = yield call(login, OAuthURI);
    token = OAuthToken;
  } catch (e) {
    console.log('oauth flow error', e);
    yield put({ type: OAUTH_GRANT_FLOW_FAILED });
    return;
  }

  yield put.resolve(userModule.fetchUser({ token }));
  yield put(OAuthGrantSuccess({ OAuthToken: token }));
}

function* watchOAuthGrantRequest() {
  yield takeLatest(REQUEST_OAUTH_GRANT, requestOAuthGrant);
}

export default function* root() {
  yield all([fork(watchOAuthGrantRequest)]);
}
{'fraction_non_alphanumeric': 0.1373873873873874, 'fraction_numerical': 0.0, 'mean_word_length': 4.501547987616099, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3220423', 'n_tokens_mistral': 619, 'n_tokens_neox': 593, 'n_words': 140}