<commit_before>import Em from 'ember';
import UnauthenticatedRouteMixin from 'ember-simple-auth/mixins/unauthenticated-route-mixin';

export default Em.Route.extend(UnauthenticatedRouteMixin, {
    beforeModel() {
        // Acquire an OSF access token, then exchange it for a Jam token
        this._super(...arguments);
        var hash = window.location.hash.substring(1).split('&').map(function(str) {
            return this[str.split('=')[0]] = str.split('=')[1], this;
        }.bind({}))[0];
        window.location.hash = '';
        if (!hash.access_token) {
            return null;
        }
        return this.get('session').authenticate('authenticator:jam-osf-jwt', hash.access_token, hash.expires_in)
            .then((data) => {
                this.transitionTo('experiments');})
            .catch((reason) => {
                this.set('errorMessage', 'User does not have permissions on the domain'); // TODO: Does this display?
            });
    },

    setupController(controller, model) {
        this._super(...arguments);
        controller.set('errorMessage', this.get('errorMessage'));<commit_msg>Submit OSF user ID (rather than permissions string)<commit_after>import Em from 'ember';
import UnauthenticatedRouteMixin from 'ember-simple-auth/mixins/unauthenticated-route-mixin';

export default Em.Route.extend(UnauthenticatedRouteMixin, {
    beforeModel() {
        // Acquire an OSF access token, then exchange it for a Jam token
        this._super(...arguments);
        var hash = window.location.hash.substring(1).split('&').map(function(str) {
            return this[str.split('=')[0]] = str.split('=')[1], this;
        }.bind({}))[0];
        window.location.hash = '';
        if (!hash.access_token) {
            return null;
        }
        return this.get('session').authenticate('authenticator:jam-osf-jwt', hash.access_token, hash.expires_in)
            .then((data) => {
                this.transitionTo('experiments');})
            .catch((reason) => {
                // TODO: Pick failure reason off the response for custom messages
                this.set('errorMessage', 'User does not have permissions on the domain');
            });
    },

    setupController(controller, model) {
        this._super(...arguments);
        controller.set('errorMessage', this.get('errorMessage'));
{'fraction_non_alphanumeric': 0.14876385336743392, 'fraction_numerical': 0.0034100596760443308, 'mean_word_length': 2.621913580246914, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '5480746', 'n_tokens_mistral': 668, 'n_tokens_neox': 644, 'n_words': 138}