<commit_before>/* eslint-disable no-param-reassign */

import axios from 'axios';

import auth from '../../utils/auth';
import {
  extractUser,
  setFlag,
  clearFlag,
  isLoggedIn,
} from '../../utils/auth-actions';
import { LoggedOutError, Auth0Error } from '../../errors';

function createDefaultState() {
  return {
    token: '',
    details: {
      nickname: '',
      email: '',
      emailVerified: false,
    },
  };
}

const mutations = {
  SET_TOKEN(state, token) {
    state.token = token;
  },

  SET_DETAILS(state, details) {
    state.details = details;
  },
};

const actions = {
  getUser: ({ commit }) =>
    new Promise((resolve, reject) => {
      if (isLoggedIn()) {
        auth.checkSession(
          { responseType: 'id_token token' },
          (err, authResult) => {
            const { idToken, accessToken, idTokenPayload } = authResult;

            if (err && err.error === 'login_required') {
              clearFlag();
              return reject(new LoggedOutError());
            }
            if (err || !idToken || !accessToken || !idTokenPayload) {
              clearFlag();
              return reject(new Auth0Error());
            }

            commit('SET_TOKEN', idToken);
            commit('SET_DETAILS', extractUser(idTokenPayload));
            axios.defaults.headers.common.Authorization = `Bearer ${accessToken}`;
            setFlag();
            return resolve();
          }
        );
      } else {
        clearFlag();
        reject(new LoggedOutError());
      }
    }),
};

export default {
  namespaced: true,
  state: createDefaultState(),
  mutations,
  actions,
  getters: {},
};<commit_msg>do not include auth0 access token in every request<commit_after>/* eslint-disable no-param-reassign */

import auth from '../../utils/auth';
import {
  extractUser,
  setFlag,
  clearFlag,
  isLoggedIn,
} from '../../utils/auth-actions';
import { LoggedOutError, Auth0Error } from '../../errors';

function createDefaultState() {
  return {
    idToken: '',
    accessToken: '',
    details: {
      nickname: '',
      email: '',
      emailVerified: false,
    },
  };
}

const mutations = {
  SET_ID_TOKEN(state, idToken) {
    state.idToken = idToken;
  },

  SET_ACCESS_TOKEN(state, accessToken) {
    state.accessToken = accessToken;
  },

  SET_DETAILS(state, details) {
    state.details = details;
  },
};

const actions = {
  getUser: ({ commit }) =>
    new Promise((resolve, reject) => {
      if (isLoggedIn()) {
        auth.checkSession(
          { responseType: 'id_token token' },
          (err, authResult) => {
            const { idToken, accessToken, idTokenPayload } = authResult;

            if (err && err.error === 'login_required') {
              clearFlag();
              return reject(new LoggedOutError());
            }
            if (err || !idToken || !accessToken || !idTokenPayload) {
              clearFlag();
              return reject(new Auth0Error());
            }

            commit('SET_ID_TOKEN', idToken);
            commit('SET_ACCESS_TOKEN', accessToken);
            commit('SET_DETAILS', extractUser(idTokenPayload));
            setFlag();
            return resolve();
          }
        );
      } else {
        clearFlag();
        reject(new LoggedOutError());
      }
    }),
};

export default {
  namespaced: true,
  state: createDefaultState(),
  mutations,
  actions,
  getters: {},
};
{'fraction_non_alphanumeric': 0.14566236811254396, 'fraction_numerical': 0.0014654161781946073, 'mean_word_length': 2.1225983531564503, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '1558872', 'n_tokens_mistral': 1011, 'n_tokens_neox': 1008, 'n_words': 212}