PageSourceSearch

https://www.barkerbusiness.co.nz/app/js/controllers/contact/contac…?1509202000?b=c7d7c6928a49b8

js barkerbusiness.co.nz collected 2026-10-06 16:20:57 UTC 4,195 bytes, 128 lines download raw bytes

1/**
2 * Controller for the Contact Login Form
3 *
4 * @param $scope
5 * @returns {*}
6 * @constructor
7 */
8app.controller('ContactAuthLoginFormController',
9    ['$scope', '$timeout', '$filter', '$http', function ($scope, $timeout, $filter, $http) {
10
11        var initScopeData = function () {
12            $scope.data = {
13                email: null,
14                password: null,
15                rememberMe: false
16            };
17
18            $scope.formProgress = {
19                loading: false,
20                submitted: false,
21                success: false,
22                responseMessage: null
23            };
24        };
25
26        var formProgressLoading = function () {
27            $scope.formProgress = {
28                loading: true,
29                submitted: false,
30                success: false,
31                responseMessage: null
32            };
33        };
34
35        var formProgressSubmitted = function (data) {
36            $scope.formProgress.loading = false;
37            $scope.formProgress.submitted = true;
38            $scope.formProgress.success = data.success;
39            $scope.formProgress.responseMessage = !_.isUndefined(data.responseMessage) ? data.responseMessage : null;
40        };
41
42        var initWatchers = function () {
43            // for back button auto complete
44            $scope.$watchCollection('[data.email, data.password]', function (data) {
45                $timeout(function () {
46                    var emailElementValue = $('#' + $scope.formUniqueId + '_email').val();
47                    var passwordElementValue = $('#' + $scope.formUniqueId + '_password').val();
48
49                    if (!data[0] && emailElementValue) {
50                        $scope.data.email = emailElementValue;
51                    }
52
53                    if (!data[1] && passwordElementValue) {
54                        $scope.data.password = passwordElementValue;
55                    }
56                });
57            });
58        };
59
60        var initScopeMethods = function () {
61            /**
62             * Receive the uniqueId, and do some other initializations.
63             *
64             * @param string  uniqueId
65             */
66            $scope.init = function (formUniqueId) {
67                $scope.formUniqueId = formUniqueId;
68            };
69
70            $scope.login = function () {
71                if ($scope.form.$invalid) {
72                    return;
73                }
74
75                formProgressLoading();
76
77                $http.post('/submit/login', $scope.data).success(function (data) {
78                    formProgressSubmitted(data);
79                    if (!data.success) {
80                        return;
81                    }
82
83                    $http.post('/profile/get_profile').success(function (profile) {
84                      if (!_.isUndefined(profile) && !_.isEmpty(profile) && profile.contactAccountId) {
85                          localStorage.setItem('authName', profile.firstName1 + ' ' + profile.lastName1);
86                      }
87                  });
88
89                    if (document.referrer) {
90                        var url = new URL(document.referrer);
91                        var path = _.first(_.filter(url.pathname.split('/'), _.size));
92
93                        var invalidRedirectPaths = [
94                            'login',
95                            'register',
96                            'register_confirm',
97                            'password_reset',
98                            'password_change'
99                        ];
100
101                        if (path && !_.contains(invalidRedirectPaths, path)) {
102                            window.location = document.referrer;
103                            return;
104                        }
105                    }
106
107                    // window.location = '/profile/finder';
108                    window.location = '/profile';
109                });
110            };
111
112            $scope.passwordReset = function () {
113                window.location = '/password_reset';
114            };
115        };
116
117        var init = function () {
118            initScopeData();
119            initScopeMethods();
120            initWatchers();
121        };
122
123        init();
124
125
126        return $scope;
127
128    }]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.