<commit_before>angular.module('controllers').controller('userCtrl', function($scope, $routeParams, userService, $location) {
        $scope.findOne = function() {
            userService.get({
                userId: $routeParams.id
            }, function(foundUser) {
                $scope.selectedUser = foundUser;
            }, function(){
                $scope.alerts = [
                    { type: 'danger', msg: "Failed load using the id " + $routeParams.id }
                ];
            });
        };
        $scope.passwordChange = {};
        $scope.submitPasswordChange = function(){
            if ($scope.passwordChange.existingPassword != null && $scope.passwordChange.newPassword != null && $scope.passwordChange.confirmPassword != null){
                if ($scope.passwordChange.newPassword == $scope.passwordChange.confirmPassword){
                    userService.changePassword($scope.passwordChange).then(function(){
                            $scope.alerts = [
                                { type: 'success', msg: "Your password has been updated"}
                            ];
                            $scope.passwordChange = {};
                        },
                        function(failedResponse){
                            $scope.alerts = [
                                { type: 'danger', msg: "Failed to update your password - reason: " + failedResponse.data.error }
                            ];
                        }
                    );
                } else {
                    $scope.alerts = [
                        { type: 'danger', msg: "Your new password and confirmed passwords do not match"}
                    ];
                }
            } else {
                $scope.alerts = [
                    { type: 'danger', msg: "You must complete all fields"}
                ];
            }
        };

        $scope.submitPasswordChangeToken = function(){
            if ($scope.passwordChange.newPassword != null && $scope.passwordChange.confirmPassword != null){
                if ($scope.passwordChange.newPassword == $scope.passwordChange.confirmPassword){
                    userService.changePasswordToken($routeParams.token, $scope.passwordChange).then(function(){
                            $scope.alerts = [
                                { type: 'success', msg: "Your password has been updated"}
                            ];
                            $scope.passwordChange = {};
                            $scope.passwordChanged = true;
                        },
                        function(failedResponse){
                            $scope.alerts = [
                                { type: 'danger', msg: "Failed to update your password - reason: " + failedResponse.data.error }
                            ];
                        }
                    );
                } else {
                    $scope.alerts = [
                        { type: 'danger', msg: "Your new password and confirmed passwords do not match"}
                    ];
                }
            } else {
                $scope.alerts = [
                    { type: 'danger', msg: "You must complete all fields"}
                ];
            }
        };

        $scope.checkToken = function(){
            userService.findToken($routeParams.token).then(function(){
                    $scope.tokenStatus = 'valid';
                },
                function(failedResponse){
                    $scope.tokenStatus = 'invalid';
                }
            );
        };
        $scope.passwordResetSent = false;
        $scope.sendForgotPasswordRequest = function(){
            userService.forgotPassword($scope.forgot).then(function(data){
                    $scope.alerts = [
                        { type: 'primary', msg: "We have sent an email to " + $scope.forgot.email + " with further instructions" }
                    ];
                    $scope.passwordResetSent = true;
                },
                function(failedResponse){
                    $scope.alerts = [
                        { type: 'danger', msg: failedResponse.data.error }
                    ];
                }
            );
        };

        $scope.createUser = function(){
            userService.save({}, $scope.selectedUser, function(response){
                    $location.path('user/view/'+ response._id);
                },
                function(error){
                    $scope.alerts = [
                        { type: 'danger', msg: "create failed - " + error.data.error }
                    ];
                });
        };

        $scope.signUp = function(){
            userService.signUp($scope.user).then(function(){
                $scope.registeredSuccess = true;
            }, function(failedResponse){
                $scope.alerts = [
                    { type: 'danger', msg: "Failed to register user: " + failedResponse.data.error }
                ];
            });
        };

        $scope.save = function(){
            $scope.selectedUser.$update(function(data){
                    $scope.alerts = [
                        { type: 'success', msg: "Updated user" }
                    ];
                    $scope.selectedUser = data;
                },
                function(error){
                    console.log(error.data);
                    $scope.alerts = [
                        { type: 'danger', msg: error.data.error }<commit_msg>Auto login with the user was actually created<commit_after>angular.module('controllers').controller('userCtrl', function($scope,
                                                              $routeParams,
                                                              userService,
                                                              rankerEventBus,
                                                              securityService,
                                                              $location,
                                                              $window) {
        $scope.findOne = function() {
            userService.get({
                userId: $routeParams.id
            }, function(foundUser) {
                $scope.selectedUser = foundUser;
            }, function(){
                $scope.alerts = [
                    { type: 'danger', msg: "Failed load using the id " + $routeParams.id }
                ];
            });
        };
        $scope.passwordChange = {};
        $scope.submitPasswordChange = function(){
            if ($scope.passwordChange.existingPassword != null && $scope.passwordChange.newPassword != null && $scope.passwordChange.confirmPassword != null){
                if ($scope.passwordChange.newPassword == $scope.passwordChange.confirmPassword){
                    userService.changePassword($scope.passwordChange).then(function(){
                            $scope.alerts = [
                                { type: 'success', msg: "Your password has been updated"}
                            ];
                            $scope.passwordChange = {};
                        },
                        function(failedResponse){
                            $scope.alerts = [
                                { type: 'danger', msg: "Failed to update your password - reason: " + failedResponse.data.error }
                            ];
                        }
                    );
                } else {
                    $scope.alerts = [
                        { type: 'danger', msg: "Your new password and confirmed passwords do not match"}
                    ];
                }
            } else {
                $scope.alerts = [
                    { type: 'danger', msg: "You must complete all fields"}
                ];
            }
        };

        $scope.submitPasswordChangeToken = function(){
            if ($scope.passwordChange.newPassword != null && $scope.passwordChange.confirmPassword != null){
                if ($scope.passwordChange.newPassword == $scope.passwordChange.confirmPassword){
                    userService.changePasswordToken($routeParams.token, $scope.passwordChange).then(function(){
                            $scope.alerts = [
                                { type: 'success', msg: "Your password has been updated"}
                            ];
                            $scope.passwordChange = {};
                            $scope.passwordChanged = true;
                        },
                        function(failedResponse){
                            $scope.alerts = [
                                { type: 'danger', msg: "Failed to update your password - reason: " + failedResponse.data.error }
                            ];
                        }
                    );
                } else {
                    $scope.alerts = [
                        { type: 'danger', msg: "Your new password and confirmed passwords do not match"}
                    ];
                }
            } else {
                $scope.alerts = [
                    { type: 'danger', msg: "You must complete all fields"}
                ];
            }
        };

        $scope.checkToken = function(){
            userService.findToken($routeParams.token).then(function(){
                    $scope.tokenStatus = 'valid';
                },
                function(failedResponse){
                    $scope.tokenStatus = 'invalid';
                }
            );
        };
        $scope.passwordResetSent = false;
        $scope.sendForgotPasswordRequest = function(){
            userService.forgotPassword($scope.forgot).then(function(data){
                    $scope.alerts = [
                        { type: 'primary', msg: "We have sent an email to " + $scope.forgot.email + " with further instructions" }
                    ];
                    $scope.passwordResetSent = true;
                },
                function(failedResponse){
                    $scope.alerts = [
                        { type: 'danger', msg: failedResponse.data.error }
                    ];
                }
            );
        };

        $scope.createUser = function(){
            userService.save({}, $scope.selectedUser, function(response){
                    $location.path('user/view/'+ response._id);
                },
                function(error){
                    $scope.alerts = [
                        { type: 'danger', msg: "create failed - " + error.data.error }
                    ];
                });
        };

        $scope.signUp = function(){
            userService.signUp($scope.user).then(function(user){
                if (user.state == "Active"){
                    console.log(user);
                    var login = {email: $scope.user.email, password: $<PASSWORD>};
                    securityService.signIn(login).then(function(result){
                        rankerEventBus.broadcastEvent(rankerEventBus.EVENTS.USER_LOGIN, result.data);
                        $scope.alerts = [
                            { type: 'success', msg: "Login successful" }
                        ];
                        $window.location.href = '/';
                    }, function(error){
                        $scope.alerts = [
                            { type: 'danger', msg: "Failed to login: " + error.data.error }
                        ];
                    });
                } else {
                    $scope.registeredSuccess = true;
                }
            }, function(failedResponse){
                $scope.alerts = [
                    { type: 'danger', msg: "Failed to register user: " + failedResponse.data.error }
                ];
            });
        };

        $scope.save = function(){
            $scope.selectedUser.$update(function(data){
                    $scope.alerts = [
                        { type: 'success', msg: "Updated user" }
                    ];
                    $scope.selectedUser = data;
                },
                function(error){
                    console.log(error.data);
                    $scope.alerts = [
                        { type: 'danger', msg: error.data.error }
{'fraction_non_alphanumeric': 0.10935839803841438, 'fraction_numerical': 0.0, 'mean_word_length': 1.04512786227645, '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': 20, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '642873', 'n_tokens_mistral': 2766, 'n_tokens_neox': 2566, 'n_words': 494}