<commit_before>import * as api from '../connectivity/api';
import {startSubmit, stopSubmit} from 'redux-form';
import {call, put} from 'redux-saga/effects';
import {takeLatest, delay} from 'redux-saga';
import jwtDecode from 'jwt-decode';
import {push} from 'react-router-redux';
import * as types from '../constants/actionTypes';

export function *doLogin(action) {

  try {

    yield put(startSubmit('login'));

    yield put({
      type: types.SENDING_REQUEST,
      payload: {
        sendingRequest: true
      }
    });

    const {username, password} = action.payload;

    const responseBody = yield call(api.login, username, password);

    if (typeof responseBody.token === "undefined") {
      throw new Error('Unable to find JWT in response body');
    }

    yield call(delay, 5000);

    yield put({
      type: types.LOGIN__SUCCEEDED,
      payload: {
        idToken: responseBody.token
      }
    });

  } catch (e) {

    yield put({
      type: types.LOGIN__FAILED,
      payload: {
        message: e.message,
        statusCode: e.statusCode
      }
    });

  } finally {

    yield put({
      type: types.SENDING_REQUEST,
      payload: {
        sendingRequest: false
      }
    });

    yield put(stopSubmit('login'));

  }
}


export function *watchLogin() {
  yield takeLatest(types.LOGIN__REQUESTED, doLogin);
}





<commit_msg>vid-14 auth saga changes<commit_after>import * as api from '../connectivity/api';
import {call, put} from 'redux-saga/effects';
import {takeLatest, delay} from 'redux-saga';
import jwtDecode from 'jwt-decode';
import {push} from 'react-router-redux';
import * as types from '../constants/actionTypes';

export function *doLogin(action) {

  try {

    yield put({
      type: types.SENDING_REQUEST,
      payload: {
        sendingRequest: true
      }
    });

    const {username, password} = action.payload;

    const responseBody = yield call(api.login, username, password);

    if (typeof responseBody.token === "undefined") {
      throw new Error('Unable to find JWT in response body');
    }

    yield call(delay, 5000);

    yield put({
      type: types.LOGIN__SUCCEEDED,
      payload: {
        idToken: responseBody.token
      }
    });

  } catch (e) {

    yield put({
      type: types.LOGIN__FAILED,
      payload: {
        message: e.message,
        statusCode: e.statusCode
      }
    });

  } finally {

    yield put({
      type: types.SENDING_REQUEST,
      payload: {
        sendingRequest: true
      }
    });

  }
}


export function *watchLogin() {
  yield takeLatest(types.LOGIN__REQUESTED, doLogin);
}






{'fraction_non_alphanumeric': 0.12581511315688532, 'fraction_numerical': 0.0038358266206367474, 'mean_word_length': 2.5873452544704265, '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': '5966454', 'n_tokens_mistral': 846, 'n_tokens_neox': 805, 'n_words': 206}