1 2const _authenticationCtrl = function($scope, $rootScope, $http, $mdToast, $timeout, $location,$window){ 3 4 5 $scope.login_status = "Login"; 6 $scope.disabled_status = false; 7 $scope.userlogin = false; 8 9 10 $scope.initLoginFunction = function() 11 { 12 13 $http.post( 14 `${BASE_URL}/api/auth/invalidlogin.php?invaliduser`).then(function(httpResponse) 15 { 16 var apiResponse = httpResponse.data; 17 18 $scope.invalidcount = apiResponse.result; 19 20 if($scope.invalidcount>5) 21 { 22 $scope.userlogin = true; 23 } 24 25 }); 26 27 // let whoWasLoggedIn = localStorage.getItem('ltuser'); 28 29 // if(whoWasLoggedIn == 'admin') 30 // { 31 // $window.location = '/admin/'; 32 // } 33 // else if(whoWasLoggedIn == 'user') 34 // { 35 // $window.location = '/user/'; 36 // } 37 } 38 39 $scope.loginFun = function() 40 { 41 if($scope.user_name.length==0){ 42 $scope.loginErrorMessage = "Invalid username!"; 43 return; 44 } 45 if($scope.password.length==0){ 46 $scope.loginErrorMessage = "Invalid password!"; 47 return; 48 } 49 50 $scope.login_status = "Logging..."; 51 $scope.disabled_status = true; 52 53 $scope.clearTokenFunction(); 54 55 $http.post( 56 `${BASE_URL}/api/auth/login.php`, 57 { 58 "user_name" : $scope.user_name, 59 "password" : $scope.password, 60 "use_device" : 'desktop' // OPTIONAL: for other device like :android,ios 61 } 62 ).then(function(httpResponse) 63 { 64 var apiResponse = httpResponse.data; 65 66 $scope.loginResponse = apiResponse; 67 68 $scope.timeIntervalLogin(); 69 70 if(!apiResponse.complete){ 71 $scope.login_status = "Login"; 72 $scope.disabled_status = false;
73 return; 74 } 75 $scope.disabled_status = true; 76 $scope.login_status = "Logging..."; 77 localStorage.setItem('smtkn', apiResponse.token); 78 // localStorage.setItem('ltuser', data.login_Type); 79 80 $timeout(function(){ 81 $window.location = apiResponse.redirectTo; 82 }, 2000); 83 }); 84 }; 85 $scope.timeIntervalLogin=function() 86 { 87 $scope.showLoginError=true; 88 $timeout(function() 89 { 90 $scope.showLoginError = false; 91 }, 5000); 92 } 93 94 $scope.clearTokenFunction = function() 95 { 96 localStorage.removeItem('smtkn'); 97 localStorage.clear(); 98 } 99 100 $scope.reset_password_button = "Reset Password"; 101 $scope.reset_password_disabled_status = false; 102 103 // SEND RESET PASSWORD EMAIL TO USER 104 $scope.sendResetPasswordLinkToUser = function() 105 { 106 $scope.reset_password_button = "Wait..."; 107 $scope.reset_password_disabled_status = true; 108 109 $http.post( 110 `${BASE_URL}/api/registration/password-setup.php?action=send-link`, 111 { 112 "user_name" : $scope.user_name 113 } 114 ).success( 115 function(data, status, headers, config) 116 { 117 $scope.resetPasswordResponse = data; 118 119 $scope.timeIntervalResetPassword(); 120 121 if(data.complete == false) 122 { 123 $scope.reset_password_button = "Reset Password"; 124 $scope.reset_password_disabled_status = false; 125 } 126 else 127 { 128 $scope.reset_password_button = "Reset Password"; 129 $scope.reset_password_disabled_status = true; 130 131 $timeout(function(){ 132 $window.location = 'login'; 133 }, 5000); 134 } 135 } 136 ); 137 } 138 139 $scope.timeIntervalResetPassword=function() 140 { 141 $scope.showPasswordResponse=true; 142 $timeout(function() 143 { 144 $scope.showPasswordResponse = false; 145 }, 10000); 146 } 147 148}; 149 150app.controller( 151 "authenticationCtrl", 152 [ 153 "$scope", 154 "$rootScope", 155 "$http", 156 "$mdToast", 157 "$timeout", 158 "$location", 159 "$window", 160 _authenticationCtrl 161 ] 162);
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.