<commit_before>'use strict'

var cookies = require('../cookies')
var browser = require('../browser')
var adminUrls = require('../admin-urls')
var ajax = require('../ajax')
var BaseViewModel = require('./BaseViewModel')

function Index () {
  var self = this
  self.init = function () {
    var sessionToken = cookies.get('session-token')

    var adminForPrefix = 'AdminFor:'

    var success = (result) => {
      var authClaims = result.data.authClaims
      if (authClaims.indexOf('SuperAdmin') > -1) {
        browser.redirect(adminUrls.dashboard)
      } else if (authClaims.indexOf('CharterAdmin') > -1) {
        browser.redirect(adminUrls.charter)
      } else {
        let adminForClaim = authClaims.filter((a) => a.indexOf(adminForPrefix) === 0)
        if (adminForClaim.length > 0) {
          let providerKey = adminForClaim[0].substring(adminForPrefix.length)
          var destination = adminUrls.serviceProviders + '?key=' + providerKey
          browser.redirect(destination)
        }
      }
    }

    var error = () => {
      browser.redirect(adminUrls.login)
    }
<commit_msg>adminfor redirect takes precedence<commit_after>'use strict'

var cookies = require('../cookies')
var browser = require('../browser')
var adminUrls = require('../admin-urls')
var ajax = require('../ajax')
var BaseViewModel = require('./BaseViewModel')

function Index () {
  var self = this
  self.init = function () {
    var sessionToken = cookies.get('session-token')

    var adminForPrefix = 'AdminFor:'

    var success = (result) => {
      var authClaims = result.data.authClaims
      let adminForClaim = authClaims.filter((a) => a.indexOf(adminForPrefix) === 0)
      if (adminForClaim.length > 0) {
        let providerKey = adminForClaim[0].substring(adminForPrefix.length)
        var destination = adminUrls.serviceProviders + '?key=' + providerKey
        browser.redirect(destination)
      } else if (authClaims.indexOf('SuperAdmin') > -1) {
        browser.redirect(adminUrls.dashboard)
      } else if (authClaims.indexOf('CharterAdmin') > -1) {
        browser.redirect(adminUrls.charter)
      }
    }

    var error = () => {
      browser.redirect(adminUrls.login)
    }

{'fraction_non_alphanumeric': 0.14123006833712984, 'fraction_numerical': 0.004555808656036446, 'mean_word_length': 3.036764705882353, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '477240', 'n_tokens_mistral': 662, 'n_tokens_neox': 648, 'n_words': 135}