summary refs log tree commit diff
path: root/webclient/components
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/components
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/components')
-rw-r--r--webclient/components/matrix/matrix-service.js21
1 files changed, 1 insertions, 20 deletions
diff --git a/webclient/components/matrix/matrix-service.js b/webclient/components/matrix/matrix-service.js
index 81ccdc2cc0..132c996f7a 100644
--- a/webclient/components/matrix/matrix-service.js
+++ b/webclient/components/matrix/matrix-service.js
@@ -49,32 +49,13 @@ angular.module('matrixService', [])
         if (path.indexOf(prefixPath) !== 0) {
             path = prefixPath + path;
         }
-        // Do not directly return the $http instance but return a promise
-        // with enriched or cleaned information
-        var deferred = $q.defer();
-        $http({
+        return $http({
             method: method,
             url: baseUrl + path,
             params: params,
             data: data,
             headers: headers
         })
-        .success(function(data, status, headers, config) {
-            deferred.resolve(data, status, headers, config);
-        })
-        .error(function(data, status, headers, config) {
-            // Enrich the error callback with an human readable error reason
-            var reason = data.error;
-            if (!data.error) {
-                reason = JSON.stringify(data);
-            }
-            deferred.reject(reason, data, status, headers, config);
-
-            if (403 === status && "M_UNKNOWN_TOKEN" === data.errcode) {
-                // The access token is no more valid, broadcast the issue
-                $rootScope.$broadcast("M_UNKNOWN_TOKEN");
-            }
-        });
 
         return deferred.promise;
     };