<commit_before>/* global escape */

define(['app', 'angular', 'authentication', 'utilities/km-utilities'], function() { 'use strict';

	return ['$scope', '$rootScope', '$route', '$browser', '$location', '$window', 'user', 'authentication', function ($scope, $rootScope, $route, $browser, $location, $window, user, authentication) {

        $rootScope.homePage = true;
        $rootScope.userGovernment = user.government;
        $rootScope.navigation = [];
        $rootScope.navigationTree = [];

        $scope.email = $browser.cookies().lastLoginEmail || "";
        $scope.rememberMe = !!$browser.cookies().lastLoginEmail;

        //========================================
        //
        //========================================
        $scope.signIn = function () {

            var sEmail = $scope.email;
            var sPassword = $scope.password;

            authentication.signIn(sEmail, sPassword).then(function () { // Success
                $scope.password = "";
                $scope.setCookie("lastLoginEmail", $scope.rememberMe ? sEmail : undefined, 365, '/');
                authentication.getUser().then(function () { $location.path("/management"); });
            },
            function (error) { // Error
                $scope.password = "";
                $scope.isLoading = false;
                $scope.isForbidden = error.errorCode == 403;
                $scope.isNoService = error.errorCode == 404;
                $scope.isError = error.errorCode != 403 && error.errorCode != 404;
                $scope.error = error.error;
                throw error;
            });
        };

        //========================================
        //
        //========================================
        $scope.setCookie = function (name, value, days, path) {
            var sCookieString = escape(name) + "=";

            if (value) sCookieString += escape(value);
            else days = -1;

            if (path)
                sCookieString += "; path=" + path;

            if (days || days === 0) {
                var oExpire = new Date();

                oExpire.setDate(oExpire.getDate() + days);

                sCookieString += "; expires=" + oExpire.toUTCString();
            }

            $window.document.cookie = sCookieString;
        };
    }];
});
<commit_msg>Use lastLogin from rootscope instead of cookie<commit_after>define(['app', 'angular', 'authentication', 'utilities/km-utilities'], function() { 'use strict';

	return ['$scope', '$rootScope', '$route', '$browser', '$location', '$window', 'user', 'authentication', function ($scope, $rootScope, $route, $browser, $location, $window, user, authentication) {

        $rootScope.homePage = true;
        $rootScope.userGovernment = user.government;
        $rootScope.navigation = [];
        $rootScope.navigationTree = [];

        $scope.email = $rootScope.lastLoginEmail || "";

        //========================================
        //
        //========================================
        $scope.signIn = function () {

            var sEmail = $scope.email;
            var sPassword = $scope.password;

            authentication.signIn(sEmail, sPassword).then(function () { // Success
                $scope.password = "";
                authentication.getUser().then(function () { $location.path("/management"); });
            },
            function (error) { // Error
                $scope.password = "";
                $scope.isLoading = false;
                $scope.isForbidden = error.errorCode == 403;
                $scope.isNoService = error.errorCode == 404;
                $scope.isError = error.errorCode != 403 && error.errorCode != 404;
                $scope.error = error.error;
                throw error;
            });
        };
    }];
});

{'fraction_non_alphanumeric': 0.2090217676370312, 'fraction_numerical': 0.007605559926567008, 'mean_word_length': 2.0609951845906904, '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': '5594376', 'n_tokens_mistral': 1024, 'n_tokens_neox': 944, 'n_words': 188}