<commit_before>/*
 * Controllers
 */

App.SignupController = Ember.ObjectController.extend(BB.ModalControllerMixin, App.ControllerValidationMixin, {
    createAttempt: false,
    fixedFieldsMessage: gettext('That\'s better'),
    errorsFixed: false,

    init: function() {
        this._super();

        this.set('errorDefinitions', [
            {'property': 'email', 'validateProperty': 'matchingEmail', 'message': gettext('Emails don\'t match')},
            {'property': 'password', 'validateProperty': 'validPassword', 'message': Em.get(App, 'settings.minPasswordError')},
        ]);

        this._clearModel();
    },

    _clearModel: function () {
        var user = App.UserCreate.createRecord({
            first_name: '',
            last_name: '',
        });

        this.set('model', user);
    },

    willClose: function () {
        this._clearModel();
    },

    // Check if there were previous errors which are now fixed
    checkErrors: function() {
        if (this.get('validationErrors')){
            this.set('validationErrors', this.validateErrors(this.get('errorDefinitions'), this.get('model'), true));
            if (!this.get('validationErrors')) {
                this.set('errorsFixed', true)
            }
        }
    }.observes('password.length', 'email', 'emailConfirmation'),

    actions: {
        createUser: function(user) {
            var _this = this;

            // Clear the errors fixed message
            this.set('errorsFixed', false);

            // Ignoring API errors here, we are passing ignoreApiErrors=true
            _this.set('validationErrors', _this.validateErrors(_this.get('errorDefinitions'), _this.get('model'), true));

            // Check client side errors
            if (_this.get('validationErrors')) {
                return false
            }
            user.save().then(function(newUser) {
                var response = {
                    token: newUser.get('jwt_token')
                };

                return App.AuthJwt.processSuccessResponse(response).then(function (authorizedUser) {
                    // clear the modal fields
                    _this._clearModel();
                    
                    // This is for successfully setting the currentUser.
                    _this.set('currentUser.model', authorizedUser);
                    _this.send('close');
                    
                    // This is the users first login so flash a welcome message
                    _this.send('setFlash', this.get('currentUser.welcomeMessage'));<commit_msg>ewlcome msg fixes<commit_after>/*
 * Controllers
 */

App.SignupController = Ember.ObjectController.extend(BB.ModalControllerMixin, App.ControllerValidationMixin, {
    createAttempt: false,
    fixedFieldsMessage: gettext('That\'s better'),
    errorsFixed: false,

    init: function() {
        this._super();

        this.set('errorDefinitions', [
            {'property': 'email', 'validateProperty': 'matchingEmail', 'message': gettext('Emails don\'t match')},
            {'property': 'password', 'validateProperty': 'validPassword', 'message': Em.get(App, 'settings.minPasswordError')},
        ]);

        this._clearModel();
    },

    _clearModel: function () {
        var user = App.UserCreate.createRecord({
            first_name: '',
            last_name: '',
        });

        this.set('model', user);
    },

    willClose: function () {
        this._clearModel();
    },

    // Check if there were previous errors which are now fixed
    checkErrors: function() {
        if (this.get('validationErrors')){
            this.set('validationErrors', this.validateErrors(this.get('errorDefinitions'), this.get('model'), true));
            if (!this.get('validationErrors')) {
                this.set('errorsFixed', true)
            }
        }
    }.observes('password.length', 'email', 'emailConfirmation'),

    actions: {
        createUser: function(user) {
            var _this = this;

            // Clear the errors fixed message
            this.set('errorsFixed', false);

            // Ignoring API errors here, we are passing ignoreApiErrors=true
            _this.set('validationErrors', _this.validateErrors(_this.get('errorDefinitions'), _this.get('model'), true));

            // Check client side errors
            if (_this.get('validationErrors')) {
                return false
            }
            user.save().then(function(newUser) {
                var response = {
                    token: newUser.get('jwt_token')
                };

                return App.AuthJwt.processSuccessResponse(response).then(function (authorizedUser) {
                    // clear the modal fields
                    _this._clearModel();
                    
                    // This is for successfully setting the currentUser.
                    _this.set('currentUser.model', authorizedUser);
                    _this.send('close');

                    // This is the users first login so flash a welcome message
                    _this.send('setFlash', _this.get('currentUser.welcomeMessage'));
{'fraction_non_alphanumeric': 0.1276595744680851, 'fraction_numerical': 0.0, 'mean_word_length': 1.9877551020408164, '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': '140072', 'n_tokens_mistral': 1311, 'n_tokens_neox': 1243, 'n_words': 277}