Fetch tokens for each client separately

This commit is contained in:
Johannes Zellner
2016-06-07 12:37:04 +02:00
parent f3436a99a2
commit 4147455654
2 changed files with 15 additions and 0 deletions
+7
View File
@@ -542,6 +542,13 @@ angular.module('Application').service('Client', ['$http', 'md5', 'Notification',
}).error(defaultErrorHandler(callback));
};
Client.prototype.getTokensByClientId = function (id, callback) {
$http.get(client.apiOrigin + '/api/v1/oauth/clients/' + id + '/tokens').success(function(data, status) {
if (status !== 200) return callback(new ClientError(status, data));
callback(null, data.tokens);
}).error(defaultErrorHandler(callback));
};
Client.prototype.delTokensByClientId = function (id, callback) {
$http.delete(client.apiOrigin + '/api/v1/oauth/clients/' + id + '/tokens').success(function(data, status) {
if (status !== 204) return callback(new ClientError(status, data));
+8
View File
@@ -231,6 +231,14 @@ angular.module('Application').controller('AccountController', ['$scope', '$locat
if (error) return console.error(error);
$scope.activeClients = activeClients;
$scope.activeClients.forEach(function (client) {
Client.getTokensByClientId(client.id, function (error, result) {
if (error) console.error(error);
client.activeTokens = result || [];
});
});
});
}