Skip to content

Commit 20c6778

Browse files
committed
updated to angular 1.4.10 and the routechangestart event
1 parent 8196faf commit 20c6778

3 files changed

Lines changed: 10 additions & 9 deletions

File tree

project/static/app.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,12 @@ myApp.config(function ($routeProvider) {
3636
myApp.run(function ($rootScope, $location, $route, AuthService) {
3737
$rootScope.$on('$routeChangeStart',
3838
function (event, next, current) {
39-
AuthService.getUserStatus();
40-
if (next.access.restricted &&
41-
!AuthService.isLoggedIn()) {
42-
$location.path('/login');
43-
$route.reload();
44-
}
39+
AuthService.getUserStatus()
40+
.then(function(){
41+
if (next.access.restricted && !AuthService.isLoggedIn()){
42+
$location.path('/login');
43+
$route.reload();
44+
}
45+
});
4546
});
4647
});

project/static/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
<!-- scripts -->
1414
<script src="//code.jquery.com/jquery-2.1.4.min.js" type="text/javascript"></script>
1515
<script src="//netdna.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" type="text/javascript"></script>
16-
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.9/angular.min.js" type="text/javascript"></script>
17-
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.9/angular-route.min.js" type="text/javascript"></script>
16+
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.10/angular.min.js" type="text/javascript"></script>
17+
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.10/angular-route.min.js" type="text/javascript"></script>
1818
<script src="static/app.js" type="text/javascript"></script>
1919
<script src="static/services.js" type="text/javascript"></script>
2020
<script src="static/controllers.js" type="text/javascript"></script>

project/static/services.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ angular.module('myApp').factory('AuthService',
9999
}
100100

101101
function getUserStatus() {
102-
$http.get('/api/status')
102+
return $http.get('/api/status')
103103
// handle success
104104
.success(function (data) {
105105
if(data.status){

0 commit comments

Comments
 (0)