From db3e1d73c6a81bda3b2624596ea9b3f113242d38 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Thu, 14 Aug 2014 15:36:40 +0100 Subject: 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. --- webclient/components/matrix/matrix-service.js | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) (limited to 'webclient/components') 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; }; -- cgit 1.4.1