Specify the expiration on the client. Currently this is 100 years.

I am not sure if this is the best approach, or if we should introduce a magic value instead.
This commit is contained in:
Johannes Zellner
2016-06-07 15:54:30 +02:00
parent facdabcc8d
commit 17d48f3fce
2 changed files with 5 additions and 3 deletions

View File

@@ -549,8 +549,8 @@ angular.module('Application').service('Client', ['$http', 'md5', 'Notification',
}).error(defaultErrorHandler(callback));
};
Client.prototype.createTokenByClientId = function (id, callback) {
$http.post(client.apiOrigin + '/api/v1/oauth/clients/' + id + '/tokens').success(function(data, status) {
Client.prototype.createTokenByClientId = function (id, expiresAt, callback) {
$http.post(client.apiOrigin + '/api/v1/oauth/clients/' + id + '/tokens?expiresAt=' + expiresAt).success(function(data, status) {
if (status !== 201) return callback(new ClientError(status, data));
callback(null, data.token);
}).error(defaultErrorHandler(callback));

View File

@@ -239,7 +239,9 @@ angular.module('Application').controller('AccountController', ['$scope', '$locat
$scope.tokenAdd.busy = true;
$scope.tokenAdd.token = {};
Client.createTokenByClientId(client.id, function (error, result) {
var expiresAt = Date.now() + 100 * 365 * 24 * 60 * 60 * 1000; // ~100 years from now
Client.createTokenByClientId(client.id, expiresAt, function (error, result) {
if (error) console.error(error);
$scope.tokenAdd.busy = false;