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.
authorrougeronj
Fri, 19 Jun 2015 12:45:04 +0200
changeset 176 a8231241f50d
parent 175 d7e1920ec9ae
child 177 4a79d51d0b50
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.
client/app/app.js
--- 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) {