try to get first the context.token set up by the server. If it doesn't exist, try to get back the token in the local storage. Or get to the login page.
--- a/client/app/app.js Thu Jun 11 16:23:47 2015 +0200
+++ b/client/app/app.js Fri Jun 19 12:45:04 2015 +0200
@@ -76,10 +76,10 @@
})
.run( function($rootScope, $location, $window, $http, authApi, context) {
$rootScope.globals = {};
- if (localStorage.getItem('token') || context.token) {
+ if (context.token || localStorage.getItem('token')) {
$rootScope.globals.userLogged = true;
- localStorage.setItem('token', (localStorage.getItem('token') || context.token));
- $http.defaults.headers.common.Authorization = 'Token ' + (localStorage.getItem('token') || context.token);
+ localStorage.setItem('token', (context.token || localStorage.getItem('token') ));
+ $http.defaults.headers.common.Authorization = 'Token ' + (context.tokenĀ || localStorage.getItem('token'));
}
$rootScope.$on( '$routeChangeStart', function(event, next) {
if (next.authRequired && !$rootScope.globals.userLogged) {