PageSourceSearch

https://washingtonserverpermit.com/static/js/ng/controllers/loginController-f80d6d2d.js

js washingtonserverpermit.com collected 2026-10-04 20:44:11 UTC 2,904 bytes, 98 lines download raw bytes

1'use strict';
2angular.module('alcohest')
3.controller('loginController', ['$scope', '$rootScope','postman', 'alcohest.api', 'alcohest.session',
4function ($scope, $rootScope, postman, _api, _session) {
5	$rootScope.title = 'Login';
6	$scope.model = {
7		email: ''
8		, password: ''
9		, success: false
10		, errorMsg: ''
11		, forgot: {
12			email: ''
13			, token: ''
14			, password: ''
15			, confirm: ''
16		}
17		, currentView: 'login'
18	};
19
20	if(location.search.length) {
21		$scope.model.forgot.token = location.search.substr(1).split("&")[0].split('=')[1];
22		$scope.model.currentView = 'verify';
23	}
24
25	$scope.login = function() {
26		_api.login($scope.model.email, $scope.model.password)
27			.done(function(response) {
28				$scope.model.success = true;
29				_session.setLoggedInUser(response.data);
30				$rootScope.loggedinuser = _session.getLoggedInUser();
31				window.location.href = $rootScope.redirectTo || '/training';
32			})
33			.fail(function(err) {
34				postman.error('Login failed', err.error);
35			})
36			.always(function() {
37				$scope.$apply();
38			});
39	};
40
41	$scope.requestReset = function() {
42		_api.requestPasswordReset($scope.model.forgot.email)
43			.done(function(response) {
44				postman.success('Password request sent', 'Check your email');
45				window.location.href = '/login';
46			})
47			.fail(function(err) {
48				postman.error('Password request failed',err.error || 'Please contact the administrator');
49			})
50			.always(function() {
51				$scope.$apply();
52			});
53	};
54
55	$scope.verifyReset = function() {
56		_api.verifyPasswordReset($scope.model.forgot.email, $scope.model.forgot.token)
57			.done(function(response) {
58				$scope.model.currentView = 'reset';
59			})
60			.fail(function(err) {
61				var msg = err.error || 'Try resetting your password again or contact the admin';
62				postman.error('Password reset verification failed', msg);
63				//window.location.href = '/login';
64			})
65			.always(function() {
66				$scope.$apply();
67			});
68	};
69
70	$scope.resetPassword = function() {
71		var pw = $scope.model.forgot.password;
72		var cpw = $scope.model.forgot.confirmpassword;
73		if(pw != cpw) {
74			return postman.error('Passwords do not match');
75		}
76		if(!(/[A-Z]/.test(pw) && /[0-9]/.test(pw) && pw.length >= 6)) {
77			return postman.error('Password Invalid', '6 character minimum, at least 1 uppercase letter and 1 number');
78		}
79
80		_api.resetPassword($scope.model.forgot.email, $scope.model.forgot.token, $scope.model.forgot.password)
81			.done(function(response) {
82				_session.setLoggedInUser(response.data);
83				postman.success('Password Successfully Reset', 'You can are now logged in with your new password');
84				window.location.href = '/training';
85			})
86			.fail(function(err) {
87				postman.error('Password reset failed', err.error || 'Try again or contact administrator if this happens again');
88			})
89			.always(function() {
90				$scope.$apply();
91			});
92	};
93
94
95
96	if($rootScope.loggedinuser)
97		window.location.href = '/training';
98}]);

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.