<commit_before>define(function(require) {
    'use strict';

    var appController = require('js/app-controller');

    var LoginExistingCtrl = function($scope, $location) {
        var emailDao = appController._emailDao;

        $scope.buttonEnabled = true;
        $scope.incorrect = false;

        $scope.change = function() {
            $scope.incorrect = false;
        };

        $scope.confirmPassphrase = function() {
            if (!$scope.passphrase) {
                return;
            }

            // disable button once loggin has started
            $scope.buttonEnabled = false;
            $scope.incorrect = false;
            unlockCrypto();
        };

        function unlockCrypto() {
            var userId = emailDao._account.emailAddress;
            emailDao._keychain.getUserKeyPair(userId, function(err, keypair) {
                if (err) {
                    handleError(err);
                    return;
                }

                emailDao.unlock({
                    keypair: keypair,
                    passphrase: $scope.<PASSWORD>
                }, onUnlock);
            });
        }

        function onUnlock(err) {
            if (err) {
                $scope.incorrect = true;
                $scope.buttonEnabled = true;
                $scope.$apply();
                return;
            }

            $location.path('/desktop');
            $scope.$apply();
        }

        function handleError(err) {
            $scope.incorrect = true;
            $scope.buttonEnabled = true;
            $scope.onError(err);
        }
    };

    return LoginExistingCtrl;
});<commit_msg>Add _auth.storeCredentials again to login-existing<commit_after>define(function(require) {
    'use strict';

    var appController = require('js/app-controller');

    var LoginExistingCtrl = function($scope, $location) {
        var emailDao = appController._emailDao;

        $scope.buttonEnabled = true;
        $scope.incorrect = false;

        $scope.change = function() {
            $scope.incorrect = false;
        };

        $scope.confirmPassphrase = function() {
            if (!$scope.passphrase) {
                return;
            }

            // disable button once loggin has started
            $scope.buttonEnabled = false;
            $scope.incorrect = false;
            unlockCrypto();
        };

        function unlockCrypto() {
            var userId = emailDao._account.emailAddress;
            emailDao._keychain.getUserKeyPair(userId, function(err, keypair) {
                if (err) {
                    handleError(err);
                    return;
                }

                emailDao.unlock({
                    keypair: keypair,
                    passphrase: $scope.passphrase
                }, onUnlock);
            });
        }

        function onUnlock(err) {
            if (err) {
                $scope.incorrect = true;
                $scope.buttonEnabled = true;
                $scope.$apply();
                return;
            }

            appController._auth.storeCredentials(function(err) {
                if (err) {
                    return $scope.onError(err);
                }

                $location.path('/desktop');
                $scope.$apply();
            });
        }

        function handleError(err) {
            $scope.incorrect = true;
            $scope.buttonEnabled = true;
            $scope.onError(err);
        }
    };

    return LoginExistingCtrl;
});
{'fraction_non_alphanumeric': 0.10649202733485194, 'fraction_numerical': 0.0, 'mean_word_length': 1.317282321899736, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '2997651', 'n_tokens_mistral': 925, 'n_tokens_neox': 878, 'n_words': 161}