<commit_before>'use strict';

angular.module('<%=angularAppName%>')
    .factory('Auth', function Auth($rootScope, $state, $q, <% if (enableTranslation){ %>$translate, <% } %>Principal, AuthServerProvider, Account, Register, Activate, Password, PasswordResetInit, PasswordResetFinish<% if (websocket == 'spring-websocket') { %>, Tracker<% } %>) {
        return {
            login: function (credentials, callback) {
                var cb = callback || angular.noop;
                var deferred = $q.defer();

                AuthServerProvider.login(credentials).then(function (data) {
                    // retrieve the logged account information
                    Principal.identity(true).then(function(account) {
                      <% if (enableTranslation){ %>
                        // After the login the language will be changed to
                        // the language selected by the user during his registration
                        $translate.use(account.langKey);
                        $translate.refresh();<% } %><% if (websocket == 'spring-websocket') { %>
                        Tracker.sendActivity();<% } %>
                        deferred.resolve(data);
                    });
                    return cb();
                }).catch(function (err) {
                    this.logout();
                    deferred.reject(err);
                    return cb(err);
                }.bind(this));<commit_msg>fix login translation bug occuring when user language and current language missmatch<commit_after>'use strict';

angular.module('<%=angularAppName%>')
    .factory('Auth', function Auth($rootScope, $state, $q, <% if (enableTranslation){ %>$translate, <% } %>Principal, AuthServerProvider, Account, Register, Activate, Password, PasswordResetInit, PasswordResetFinish<% if (websocket == 'spring-websocket') { %>, Tracker<% } %>) {
        return {
            login: function (credentials, callback) {
                var cb = callback || angular.noop;
                var deferred = $q.defer();

                AuthServerProvider.login(credentials).then(function (data) {
                    // retrieve the logged account information
                    Principal.identity(true).then(function(account) {
                        <%_ if (enableTranslation){ _%>
                        // After the login the language will be changed to
                        // the language selected by the user during his registration
                        $translate.use(account.langKey).then(function(){
                            $translate.refresh();
                        });
                        <%_ } _%>
                        <%_ if (websocket == 'spring-websocket') { _%>
                        Tracker.sendActivity();
                        <%_ } _%>
                        deferred.resolve(data);
                    });
                    return cb();
                }).catch(function (err) {
                    this.logout();
                    deferred.reject(err);
                    return cb(err);
                }.bind(this));
{'fraction_non_alphanumeric': 0.12241602067183463, 'fraction_numerical': 0.0, 'mean_word_length': 1.5616211745244004, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, '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': '1117043', 'n_tokens_mistral': 764, 'n_tokens_neox': 672, 'n_words': 168}