<commit_before>import React from 'react';
import {connect} from 'react-redux';
import {Router, Route, Link} from 'react-router';

import * as actionCreators from '../action_creators';
import composePage from './base-page.jsx';

class ExternalLoginPage extends React.Component {

    constructor(props) {
        super(props);

    }

    componentDidMount() {
        // xxx there should be a better way to do this
        var parameters = window.location.href.split("?")[1].split("&");
        let token;
        let next;
        let username;
        parameters.map( (pair) => {
            let pairVals = pair.split("=");
            if ( pairVals[0] === 'token' ) {
                token = pairVals[1];
            }
            if ( pairVals[0] === 'next' ) {
                next = pairVals[1];
            }
            if ( pairVals[0] === 'username' ) {
                username = pairVals[1];
            }
        });

        debugger;

        // a token, username, and the next destination are all required to proceed
        if ( !token || !username || !next ) {
            this.props.history.pushState(null, '/');
            return;
        }

        // set the username in props
        this.props.updateField( {
            key: [ 'session', 'f_username' ],
            value: username
        });

        // set the token in props as is -- it will be validated downstream during use
        this.props.login({
            token: token
        });

        this.props.history.pushState(null, '/' + next);
    }

    render() {
        return (
            <div>
                Redirecting ...
            </div>
        );
    }
}

export const ExternalLoginPageContainer = connect(
    (state) => state.toJSON(), actionCreators
)(composePage(ExternalLoginPage));
<commit_msg>Little more succint parameter parsing<commit_after>import React from 'react';
import {connect} from 'react-redux';
import {Router, Route, Link} from 'react-router';

import * as actionCreators from '../action_creators';
import composePage from './base-page.jsx';

class ExternalLoginPage extends React.Component {

    constructor(props) {
        super(props);

    }

    componentDidMount() {
        // xxx there should be a better way to do this?
        var params = {};
        window.location.href.split("?")[1].split("&").map( (pair) => {
            let pairVals = pair.split("=");
            params[pairVals[0]] = pairVals[1];
        });

        // a token, username, and the next destination are all required to proceed
        if ( !params.token || !params.username || !params.next ) {
            this.props.history.pushState(null, '/');
            return;
        }

        // set the username in props
        this.props.updateField( {
            key: [ 'session', 'f_username' ],
            value: params.username
        });

        // set the token in props as is -- it will be validated downstream during use
        this.props.login({
            token: params.token
        });

        this.props.history.pushState(null, '/' + params.next);
    }

    render() {
        return (
            <div>
                Redirecting ...
            </div>
        );
    }
}

export const ExternalLoginPageContainer = connect(
    (state) => state.toJSON(), actionCreators
)(composePage(ExternalLoginPage));

{'fraction_non_alphanumeric': 0.13085234093637454, 'fraction_numerical': 0.003001200480192077, 'mean_word_length': 1.8414322250639386, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1200714', 'n_tokens_mistral': 940, 'n_tokens_neox': 901, 'n_words': 245}