<commit_before>/* JBoss, Home of Professional Open Source
* Copyright Red Hat, Inc., and individual contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

App.LoginController = Ember.ObjectController.extend({
    login: function() {
        var that = this;

        //TODO: more advanced validation

        if( !this.get( "password" ).trim().length ||  !this.get( "loginName" ).trim().length ) {
            this.send( "error", this, "A Username and Password are required" );
        } else {
            // Use AeroGear Authenticator to login
            App.AeroGear.authenticator.login( JSON.stringify( { loginName: this.get( "loginName" ), password: this.get( "password" ) } ), {
                contentType: "application/json",
                success: function( response, statusText, jqXHR ) {
                    if( jqXHR.status === 205 ) {
                        //change the password
                        that.set( "loginIn", false );
                    } else {
                        // Successful Login, now go to /mobileApps
                        that.transitionToRoute( "mobileApps" );
                    }
                },
                error: function() {
                    that.send( "error", that, "Login Error" );
                }
            });
        }
    },
    //Only Temporary until we can get the user create scripts
    other: function() {
        //need to send to the update endpoint
        var that = this,
            password = this.get("password"),
            loginName = this.get( "loginName" ),
            data;

        data = JSON.stringify( { loginName: loginName, password: password } );

        $.ajax({
            url: App.baseURL + "rest/auth/update",
            type: "PUT",
            data: data,
            contentType: "application/json",
            success: function() {
                that.set( "loginIn", true );
                that.transitionToRoute( "mobileApps" );
            },
            error: function() {
                that.send( "error", that, "Save Error" );
            }
        });
    }
});
<commit_msg>change password status code to 409<commit_after>/* JBoss, Home of Professional Open Source
* Copyright Red Hat, Inc., and individual contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

App.LoginController = Ember.ObjectController.extend({
    login: function() {
        var that = this;

        //TODO: more advanced validation

        if( !this.get( "password" ).trim().length ||  !this.get( "loginName" ).trim().length ) {
            this.send( "error", this, "A Username and Password are required" );
        } else {
            // Use AeroGear Authenticator to login
            App.AeroGear.authenticator.login( JSON.stringify( { loginName: this.get( "loginName" ), password: this.get( "password" ) } ), {
                contentType: "application/json",
                success: function( response, statusText, jqXHR ) {
                    if( jqXHR.status === 409 ) {
                        //change the password
                        that.set( "loginIn", false );
                    } else {
                        // Successful Login, now go to /mobileApps
                        that.transitionToRoute( "mobileApps" );
                    }
                },
                error: function() {
                    that.send( "error", that, "Login Error" );
                }
            });
        }
    },
    //Only Temporary until we can get the user create scripts
    other: function() {
        //need to send to the update endpoint
        var that = this,
            password = this.get("password"),
            loginName = this.get( "loginName" ),
            data;

        data = JSON.stringify( { loginName: loginName, password: password } );

        $.ajax({
            url: App.baseURL + "rest/auth/update",
            type: "PUT",
            data: data,
            contentType: "application/json",
            success: function() {
                that.set( "loginIn", true );
                that.transitionToRoute( "mobileApps" );
            },
            error: function() {
                that.send( "error", that, "Save Error" );
            }
        });
    }
});

{'fraction_non_alphanumeric': 0.10947368421052632, 'fraction_numerical': 0.0032535885167464117, 'mean_word_length': 1.7738853503184713, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3620153', 'n_tokens_mistral': 1351, 'n_tokens_neox': 1295, 'n_words': 451}