Blame view
app/partials/login/login.controller.js
2.55 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; |
b17e02c05
|
14 15 16 17 18 19 20 21 |
if($location.$$search && $location.$$search.tmppwd){ $scope.data.username = $location.$$search.email; $scope.data.password = $location.$$search.tmppwd; localStorage.setItem('requiredChangePwd', "Y"); } |
4bb02bb84
|
22 |
$scope.submitLogin = function() { |
67d43a8c6
|
23 24 25 |
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
|
26 |
$scope.count++ |
67d43a8c6
|
27 |
LoginService.loginUser(loginData).then(function(result) { |
5fd0d0f40
|
28 |
var reqPwdChng = localStorage.getItem("requiredChangePwd"); |
67d43a8c6
|
29 |
if(result.status == 200){ |
5fd0d0f40
|
30 31 32 |
if (reqPwdChng && reqPwdChng == "Y") { $state.go('resetPassword'); } else { |
f62f8940f
|
33 34 35 36 37 38 39 40 41 42 43 44 |
LoginService.authenticate().then(function(result){ 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){ console.log("getaccess",result) window.localStorage.setItem("EPDAccess", JSON.stringify(result.allowEpd)); window.localStorage.setItem("FMAAccess", JSON.stringify(result.allowFma)); }) } }) |
5fd0d0f40
|
45 |
} |
67d43a8c6
|
46 47 48 |
}else{ toastr.error('Username or password incorrect.', { closeButton: true |
f148ae490
|
49 50 |
}); $scope.count = 0; |
67d43a8c6
|
51 |
} |
5fd0d0f40
|
52 |
|
67d43a8c6
|
53 54 55 56 57 58 59 |
}) } }else{ toastr.error('Please enter username & password.', { closeButton: true }) } |
4bb02bb84
|
60 |
} |
feacde5ff
|
61 62 |
} })(); |