equal
deleted
inserted
replaced
72 }). |
72 }). |
73 otherwise({ |
73 otherwise({ |
74 redirectTo: '/' |
74 redirectTo: '/' |
75 }); |
75 }); |
76 }) |
76 }) |
77 .run( function($rootScope, $location, $window, $http, authApi) { |
77 .run( function($rootScope, $location, $window, $http, authApi, context) { |
78 $rootScope.globals = {}; |
78 $rootScope.globals = {}; |
79 if (localStorage.getItem('token')) { |
79 if (localStorage.getItem('token') || context['token']) { |
80 $rootScope.globals.userLogged = true; |
80 $rootScope.globals.userLogged = true; |
81 $http.defaults.headers.common.Authorization = 'Token ' + localStorage.getItem('token'); |
81 localStorage.setItem('token', (localStorage.getItem('token') || context['token'])); |
|
82 $http.defaults.headers.common.Authorization = 'Token ' + (localStorage.getItem('token') || context['token']); |
82 } |
83 } |
83 $rootScope.$on( '$routeChangeStart', function(event, next) { |
84 $rootScope.$on( '$routeChangeStart', function(event, next) { |
84 if (next.authRequired && !$rootScope.globals.userLogged) { |
85 if (next.authRequired && !$rootScope.globals.userLogged) { |
85 $location.path( '/auth/login' ); |
86 $location.path( '/auth/login' ); |
86 } |
87 } |