Commit df0e493afad66f1782cad98bdf03bfba1a2157aa
1 parent
f8afc340
logout is done but issue in page refresh.
Showing
2 changed files
with
64 additions
and
31 deletions
400-SOURCECODE/AIAHTML5.Web/app/controllers/HomeController.js
@@ -71,11 +71,14 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic | @@ -71,11 +71,14 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic | ||
71 | $rootScope.shapestyleborderWidth = 2; | 71 | $rootScope.shapestyleborderWidth = 2; |
72 | $rootScope.shapestyleborderStyles = "solid"; | 72 | $rootScope.shapestyleborderStyles = "solid"; |
73 | 73 | ||
74 | + | ||
75 | + | ||
74 | $rootScope.initializeAIA = function () { | 76 | $rootScope.initializeAIA = function () { |
75 | 77 | ||
76 | $rootScope.isLoading = false; | 78 | $rootScope.isLoading = false; |
77 | $rootScope.isVisibleLogin = true; | 79 | $rootScope.isVisibleLogin = true; |
78 | 80 | ||
81 | + getUserDetails(); | ||
79 | } | 82 | } |
80 | 83 | ||
81 | $rootScope.userInfo = { | 84 | $rootScope.userInfo = { |
@@ -87,41 +90,71 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic | @@ -87,41 +90,71 @@ function ($rootScope, Modules, $log, $location, $timeout, DataService, Authentic | ||
87 | 90 | ||
88 | $rootScope.AuthenticateUser = function (userInfo) { | 91 | $rootScope.AuthenticateUser = function (userInfo) { |
89 | $rootScope.isVisibleLogin = false; | 92 | $rootScope.isVisibleLogin = false; |
90 | - //if (userInfo.username == "" || userInfo.username == null || userInfo.password == "" || userInfo.password == null) { | 93 | + if (userInfo.username == "" || userInfo.username == null || userInfo.password == "" || userInfo.password == null) { |
91 | 94 | ||
92 | - // alert("Please enter correct information"); | 95 | + alert("Please enter correct information"); |
93 | 96 | ||
94 | - //} | ||
95 | - //else { | 97 | + } |
98 | + else { | ||
96 | 99 | ||
97 | - // AuthenticationService.authenticateUser(userInfo) | ||
98 | - // .then( | ||
99 | - | ||
100 | - // function (result) { | ||
101 | - // if (result == LoginConstants.USER_NOT_FOUND) { | ||
102 | - | ||
103 | - // alert(result); | ||
104 | - // } | ||
105 | - // else if (result == LoginConstants.ERROR_IN_FECTHING_DETAILS) { | ||
106 | - // alert(result); | ||
107 | - // } | ||
108 | - // else { | ||
109 | - // if (result.loginId != undefined || result.loginId != "" || result.loginId != null) | ||
110 | - | ||
111 | - // $rootScope.userData = result; | ||
112 | - // $rootScope.userModules = result.modules; | ||
113 | - // $rootScope.isVisibleLogin = false; | ||
114 | - // } | ||
115 | - // }, | ||
116 | - // function (error) { | ||
117 | - // console.log(' Error in authentication = ' + error.statusText); | ||
118 | - // alert(LoginConstants.ERROR_IN_FECTHING_DETAILS); | ||
119 | - // }); | ||
120 | - //} | 100 | + AuthenticationService.authenticateUser(userInfo) |
101 | + .then( | ||
102 | + | ||
103 | + function (result) { | ||
104 | + if (result == LoginConstants.USER_NOT_FOUND) { | ||
105 | + | ||
106 | + alert(result); | ||
107 | + } | ||
108 | + else if (result == LoginConstants.ERROR_IN_FECTHING_DETAILS) { | ||
109 | + alert(result); | ||
110 | + } | ||
111 | + else { | ||
112 | + if (result.loginId != undefined || result.loginId != "" || result.loginId != null) { | ||
113 | + | ||
114 | + $rootScope.userData = result; | ||
115 | + $rootScope.userModules = result.modules; | ||
116 | + $rootScope.isVisibleLogin = false; | ||
117 | + | ||
118 | + localStorage.setItem('loggedInUserDetails', JSON.stringify(result)); | ||
119 | + } | ||
120 | + } | ||
121 | + }, | ||
122 | + function (error) { | ||
123 | + console.log(' Error in authentication = ' + error.statusText); | ||
124 | + alert(LoginConstants.ERROR_IN_FECTHING_DETAILS); | ||
125 | + }); | ||
126 | + } | ||
121 | 127 | ||
122 | } | 128 | } |
123 | 129 | ||
130 | + $rootScope.LogoutUser = function () { | ||
131 | + localStorage.removeItem('loggedInUserDetails'); | ||
132 | + document.location = '/'; | ||
133 | + $rootScope.isVisibleLogin = true; | ||
134 | + } | ||
135 | + | ||
136 | + function getUserDetails() { | ||
137 | + //Retain logged in user details | ||
138 | + var currentUserDetails = localStorage.getItem('loggedInUserDetails'); | ||
139 | + if (currentUserDetails) { | ||
140 | + try { | ||
141 | + var userInfo = JSON.parse(storedUser); | ||
142 | + | ||
143 | + if (userInfo.loginId != undefined || userInfo.loginId != "" || userInfo.loginId != null) { | ||
144 | + $rootScope.isVisibleLogin = false; | ||
145 | + $rootScope.userData = userInfo; | ||
146 | + $rootScope.userModules = userInfo.modules; | ||
147 | + } | ||
148 | + } | ||
149 | + catch (e) { | ||
150 | + localStorage.removeItem('loggedInUserDetails'); | ||
151 | + } | ||
152 | + } | ||
153 | + } | ||
124 | 154 | ||
155 | + $(document).ready(function () { | ||
156 | + getUserDetails(); | ||
157 | + }); | ||
125 | 158 | ||
126 | $rootScope.$on("$locationChangeSuccess", function () { | 159 | $rootScope.$on("$locationChangeSuccess", function () { |
127 | 160 |
400-SOURCECODE/AIAHTML5.Web/app/widget/TopMenu.html
@@ -52,9 +52,9 @@ | @@ -52,9 +52,9 @@ | ||
52 | <li><a href="#">Admin</a></li> | 52 | <li><a href="#">Admin</a></li> |
53 | </ul> | 53 | </ul> |
54 | <ul class="nav navbar-nav navbar-right"> | 54 | <ul class="nav navbar-nav navbar-right"> |
55 | - <li class="visible-xs"><a href="index.html">Logout</a></li> | ||
56 | - <li class="hidden-xs marginR5" data-toggle="tooltip" data-placement="top" title="Logout"><a href="index.html"><i class="fa fa-power-off"></i></a></li> | ||
57 | - </ul> | 55 | + <li class="visible-xs"><a href="" ng-click="LogoutUser()">Logout</a></li> |
56 | + <li class="hidden-xs marginR5" data-toggle="tooltip" data-placement="top" title="Logout"><a href="" ng-click="LogoutUser()"><i class="fa fa-power-off"></i></a></li> | ||
57 | + </ul> | ||
58 | <div id="imaginary_container"> | 58 | <div id="imaginary_container"> |
59 | <div class="input-group stylish-input-group paddTop5 hidden-sm"> | 59 | <div class="input-group stylish-input-group paddTop5 hidden-sm"> |
60 | <input type="text" class="form-control width120" placeholder="Search"> | 60 | <input type="text" class="form-control width120" placeholder="Search"> |