Blame view
app/partials/login/login.controller.js
2.74 KB
feacde5ff
|
1 2 3 4 |
(function() { 'use strict' angular.module('acufuel') |
b17e02c05
|
5 |
.controller('LoginController', [ '$scope', '$filter', '$rootScope', '$state','$location', 'LoginService', LoginController]); |
67d43a8c6
|
6 |
|
b17e02c05
|
7 |
function LoginController($scope, $filter, $rootScope, $state,$location, LoginService) { |
f62f8940f
|
8 |
|
1b71872b2
|
9 |
$scope.data = {}; |
67d43a8c6
|
10 11 12 13 |
$scope.data.username = ''; $scope.data.password = ''; $scope.count = 0; var loginData; |
3b466beb3
|
14 |
localStorage.removeItem('requiredChangePwd'); |
b17e02c05
|
15 16 17 18 19 20 21 22 |
if($location.$$search && $location.$$search.tmppwd){ $scope.data.username = $location.$$search.email; $scope.data.password = $location.$$search.tmppwd; localStorage.setItem('requiredChangePwd', "Y"); } |
4bb02bb84
|
23 |
$scope.submitLogin = function() { |
67d43a8c6
|
24 25 26 |
loginData = "username=" + $scope.data.username + "&password=" + $scope.data.password; if ($scope.data.username !== '' && $scope.data.password !== '' && $scope.data.username !== undefined && $scope.data.password !== undefined) { if ($scope.count === 0) { |
671643c9f
|
27 |
$scope.count++ |
67d43a8c6
|
28 |
LoginService.loginUser(loginData).then(function(result) { |
5fd0d0f40
|
29 |
var reqPwdChng = localStorage.getItem("requiredChangePwd"); |
67d43a8c6
|
30 |
if(result.status == 200){ |
5fd0d0f40
|
31 32 33 |
if (reqPwdChng && reqPwdChng == "Y") { $state.go('resetPassword'); } else { |
f62f8940f
|
34 |
LoginService.authenticate().then(function(result){ |
9aea92263
|
35 36 |
window.localStorage.setItem("userTime", JSON.stringify(result.userProfile.userTimeZone)); |
f62f8940f
|
37 38 39 40 41 |
var currentUserDetail = JSON.parse(window.localStorage.getItem("currentUser")); if(currentUserDetail.type === 'ADDITIONAL'){ var email = $scope.data.username; //console.log("hi",email) LoginService.getAdditionalAccess(email).then(function(result){ |
9aea92263
|
42 |
// console.log("getaccess",result) |
f62f8940f
|
43 44 45 46 47 |
window.localStorage.setItem("EPDAccess", JSON.stringify(result.allowEpd)); window.localStorage.setItem("FMAAccess", JSON.stringify(result.allowFma)); }) } }) |
5fd0d0f40
|
48 |
} |
67d43a8c6
|
49 50 51 |
}else{ toastr.error('Username or password incorrect.', { closeButton: true |
f148ae490
|
52 53 |
}); $scope.count = 0; |
67d43a8c6
|
54 |
} |
5fd0d0f40
|
55 |
|
67d43a8c6
|
56 57 58 59 60 61 62 |
}) } }else{ toastr.error('Please enter username & password.', { closeButton: true }) } |
4bb02bb84
|
63 |
} |
feacde5ff
|
64 65 |
} })(); |