Add token add api and separate api tokens from rest
This commit is contained in:
@@ -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();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user