Commit 8356de6edd3cdf073ad4764fb4d86c54ba2b03c0

Authored by Kuldeep Arora
1 parent 658bb9318a
Exists in master

revert

Showing 1 changed file with 2 additions and 2 deletions   Show diff stats
app/partials/login/login.controller.js
1 (function() { 1 (function() {
2 'use strict' 2 'use strict'
3 3
4 angular.module('acufuel') 4 angular.module('acufuel')
5 .controller('LoginController', [ '$scope', '$filter', '$rootScope', '$state','$location', 'LoginService', LoginController]); 5 .controller('LoginController', [ '$scope', '$filter', '$rootScope', '$state','$location', 'LoginService', LoginController]);
6 6
7 7
8 function LoginController($scope, $filter, $rootScope, $state,$location, LoginService) { 8 function LoginController($scope, $filter, $rootScope, $state,$location, LoginService) {
9 9
10 //for hiding console errors 10 //for hiding console errors
11 window.onerror = function(message, url, lineNumber) { 11 /* window.onerror = function(message, url, lineNumber) {
12 // maybe some handling? 12 // maybe some handling?
13 return true; // prevents browser error messages 13 return true; // prevents browser error messages
14 }; 14 };*/
15 15
16 16
17 $scope.data = {}; 17 $scope.data = {};
18 $scope.data.username = ''; 18 $scope.data.username = '';
19 $scope.data.password = ''; 19 $scope.data.password = '';
20 $scope.count = 0; 20 $scope.count = 0;
21 var loginData; 21 var loginData;
22 localStorage.removeItem('requiredChangePwd'); 22 localStorage.removeItem('requiredChangePwd');
23 23
24 24
25 if($location.$$search && $location.$$search.tmppwd){ 25 if($location.$$search && $location.$$search.tmppwd){
26 26
27 $scope.data.username = $location.$$search.email; 27 $scope.data.username = $location.$$search.email;
28 $scope.data.password = $location.$$search.tmppwd; 28 $scope.data.password = $location.$$search.tmppwd;
29 localStorage.setItem('requiredChangePwd', "Y"); 29 localStorage.setItem('requiredChangePwd', "Y");
30 } 30 }
31 31
32 $scope.submitLogin = function() { 32 $scope.submitLogin = function() {
33 loginData = "username=" + $scope.data.username + "&password=" + $scope.data.password; 33 loginData = "username=" + $scope.data.username + "&password=" + $scope.data.password;
34 if ($scope.data.username !== '' && $scope.data.password !== '' && $scope.data.username !== undefined && $scope.data.password !== undefined) { 34 if ($scope.data.username !== '' && $scope.data.password !== '' && $scope.data.username !== undefined && $scope.data.password !== undefined) {
35 if ($scope.count === 0) { 35 if ($scope.count === 0) {
36 $scope.count++ 36 $scope.count++
37 LoginService.loginUser(loginData).then(function(result) { 37 LoginService.loginUser(loginData).then(function(result) {
38 var reqPwdChng = localStorage.getItem("requiredChangePwd"); 38 var reqPwdChng = localStorage.getItem("requiredChangePwd");
39 if(result.status == 200){ 39 if(result.status == 200){
40 if (reqPwdChng && reqPwdChng == "Y") { 40 if (reqPwdChng && reqPwdChng == "Y") {
41 $state.go('resetPassword'); 41 $state.go('resetPassword');
42 } else { 42 } else {
43 LoginService.authenticate().then(function(result){ 43 LoginService.authenticate().then(function(result){
44 // console.log("==usertime from api===",result) 44 // console.log("==usertime from api===",result)
45 window.localStorage.setItem("userTime", JSON.stringify(result.userProfile.userTimeZone)); 45 window.localStorage.setItem("userTime", JSON.stringify(result.userProfile.userTimeZone));
46 46
47 var currentUserDetail = JSON.parse(window.localStorage.getItem("currentUser")); 47 var currentUserDetail = JSON.parse(window.localStorage.getItem("currentUser"));
48 if(currentUserDetail.type === 'ADDITIONAL'){ 48 if(currentUserDetail.type === 'ADDITIONAL'){
49 var email = $scope.data.username; 49 var email = $scope.data.username;
50 //console.log("hi",email) 50 //console.log("hi",email)
51 LoginService.getAdditionalAccess(email).then(function(result){ 51 LoginService.getAdditionalAccess(email).then(function(result){
52 // console.log("getaccess",result) 52 // console.log("getaccess",result)
53 window.localStorage.setItem("EPDAccess", JSON.stringify(result.allowEpd)); 53 window.localStorage.setItem("EPDAccess", JSON.stringify(result.allowEpd));
54 window.localStorage.setItem("FMAAccess", JSON.stringify(result.allowFma)); 54 window.localStorage.setItem("FMAAccess", JSON.stringify(result.allowFma));
55 }) 55 })
56 } 56 }
57 }) 57 })
58 58
59 } 59 }
60 60
61 }else{ 61 }else{
62 toastr.error('Username or password incorrect.', { 62 toastr.error('Username or password incorrect.', {
63 closeButton: true 63 closeButton: true
64 }); 64 });
65 $scope.count = 0; 65 $scope.count = 0;
66 } 66 }
67 67
68 }) 68 })
69 } 69 }
70 }else{ 70 }else{
71 toastr.error('Please enter username & password.', { 71 toastr.error('Please enter username & password.', {
72 closeButton: true 72 closeButton: true
73 }) 73 })
74 } 74 }
75 } 75 }
76 } 76 }
77 })(); 77 })();
78 78
79 79