summary refs log tree commit diff
path: root/webclient/app.js
diff options
context:
space:
mode:
authorKegan Dougal <kegan@matrix.org>2014-08-14 15:36:40 +0100
committerKegan Dougal <kegan@matrix.org>2014-08-14 15:36:40 +0100
commitdb3e1d73c6a81bda3b2624596ea9b3f113242d38 (patch)
tree7c91027f8ffdee353ef4765107f89b07864325ca /webclient/app.js
parentAdded an access token interceptor to check unknown tokens. (diff)
downloadsynapse-db3e1d73c6a81bda3b2624596ea9b3f113242d38.tar.xz
Move the unknown token broadcast to the interceptor. Return the $http promise and not a wrapped one via $q. Everything now needs a level deeper nesting. Fixed registration and login.
Diffstat (limited to 'webclient/app.js')
-rw-r--r--webclient/app.js10
1 files changed, 5 insertions, 5 deletions
diff --git a/webclient/app.js b/webclient/app.js
index f869309449..0b613fa206 100644
--- a/webclient/app.js
+++ b/webclient/app.js
@@ -42,20 +42,20 @@ matrixWebClient.config(['$routeProvider', '$provide', '$httpProvider',
                 redirectTo: '/rooms'
             });
             
-        $provide.factory('AccessTokenInterceptor', function ($q) {
+        $provide.factory('AccessTokenInterceptor', ['$q', '$rootScope', 
+            function ($q, $rootScope) {
             return {
                 responseError: function(rejection) {
-                    console.log("Rejection: " + JSON.stringify(rejection));
                     if (rejection.status === 403 && "data" in rejection && 
                             "errcode" in rejection.data && 
                             rejection.data.errcode === "M_UNKNOWN_TOKEN") {
-                        console.log("TODO: Got a 403 with an unknown token. Logging out.")
-                        // TODO logout
+                        console.log("Got a 403 with an unknown token. Logging out.")
+                        $rootScope.$broadcast("M_UNKNOWN_TOKEN");
                     }
                     return $q.reject(rejection);
                 }
             };
-        });
+        }]);
         $httpProvider.interceptors.push('AccessTokenInterceptor');
     }]);