Add token add api and separate api tokens from rest

This commit is contained in:
Johannes Zellner
2020-02-07 21:40:43 +01:00
parent 467edb6b32
commit 62562f051c
2 changed files with 101 additions and 15 deletions

View File

@@ -508,10 +508,12 @@ angular.module('Application').controller('ProfileController', ['$scope', '$locat
$scope.tokens.webadminTokens = result.filter(function (c) { return c.clientId === 'cid-webadmin'; });
$scope.tokens.cliTokens = result.filter(function (c) { return c.clientId === 'cid-cli'; });
$scope.tokens.apiTokens = result.filter(function (c) { return c.clientId === 'cid-sdk'; });
console.log($scope.tokens.apiTokens)
});
},
revokeAll: function () {
revokeAllWebAndCliTokens: function () {
$scope.tokens.busy = true;
asyncForEach($scope.tokens.webadminTokens.concat($scope.tokens.cliTokens), function (token, callback) {
@@ -530,13 +532,38 @@ angular.module('Application').controller('ProfileController', ['$scope', '$locat
busy: false,
error: null,
name: '',
accessToken: '',
show: function () {
$scope.tokens.add.name = '';
$scope.tokens.add.accessToken = '';
$scope.tokens.add.busy = false;
$scope.tokens.add.error = null;
$scope.apiTokenAddForm.name.$setPristine();
$('#apiTokenAddModal').modal('show');
},
submit: function () {
$scope.tokens.add.busy = true;
Client.createToken($scope.tokens.add.name, function (error, result) {
if (error) {
if (error.statusCode === 400) {
$scope.tokens.add.error = error.message;
$scope.apiTokenAddForm.name.$setPristine();
$('#inputApiTokenName').focus();
} else {
console.error('Unable to create password.', error);
}
return;
}
$scope.tokens.add.busy = false;
$scope.tokens.add.accessToken = result.accessToken;
$scope.tokens.refresh();
});
}
},
@@ -574,7 +601,7 @@ angular.module('Application').controller('ProfileController', ['$scope', '$locat
};
// setup all the dialog focus handling
['passwordChangeModal', 'appPasswordAddModal', 'emailChangeModal', 'fallbackEmailChangeModal', 'displayNameChangeModal', 'twoFactorAuthenticationEnableModal', 'twoFactorAuthenticationDisableModal'].forEach(function (id) {
['passwordChangeModal', 'apiTokenAddModal', 'appPasswordAddModal', 'emailChangeModal', 'fallbackEmailChangeModal', 'displayNameChangeModal', 'twoFactorAuthenticationEnableModal', 'twoFactorAuthenticationDisableModal'].forEach(function (id) {
$('#' + id).on('shown.bs.modal', function () {
$(this).find("[autofocus]:first").focus();
});