<commit_before>const tokenService = require('../helpers/jwt')

/**
 *
 * @param {object} req
 * @param {object} res
 */
function logout (req, res) {
  const session = req.session
  const providerName = req.params.providerName

  if (req.uppy.providerTokens[providerName]) {
    delete req.uppy.providerTokens[providerName]
    tokenService.removeFromCookies(res, req.uppy.options, req.uppy.provider.authProviderName)
  }

  if (session.grant) {
    session.grant.state = null
    session.grant.dynamic = null
  }
  res.json({ ok: true })
}

module.exports = logout<commit_msg>companion: check that provideTokens were loaded before logging out<commit_after>const tokenService = require('../helpers/jwt')

/**
 *
 * @param {object} req
 * @param {object} res
 */
function logout (req, res) {
  const session = req.session
  const providerName = req.params.providerName

  if (req.uppy.providerTokens && req.uppy.providerTokens[providerName]) {
    delete req.uppy.providerTokens[providerName]
    tokenService.removeFromCookies(res, req.uppy.options, req.uppy.provider.authProviderName)
  }

  if (session.grant) {
    session.grant.state = null
    session.grant.dynamic = null
  }
  res.json({ ok: true })
}

module.exports = logout
{'fraction_non_alphanumeric': 0.12905844155844157, 'fraction_numerical': 0.0, 'mean_word_length': 3.9518072289156625, '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': '3399181', 'n_tokens_mistral': 405, 'n_tokens_neox': 399, 'n_words': 82}