@@ -368,31 +410,32 @@
-
-
-
Login and API Tokens
+
+
- API Tokens
+
+
+
+
+
+ +
-
+
+ You have {{ tokens.webadminTokens.length }} active web token(s), {{ tokens.cliTokens.length }} active CLI token(s) and {{ tokens.apiTokens.length }} API token(s).
-| Name | -Type | -Actions | +Name | +Expires At | +Actions |
|---|---|---|---|---|---|
| + | |||||
| No API Tokens created | +|||||
| {{ token.name || 'unnamed' }} | -- {{ token.clientId }} + | + {{ token.expiresAt | prettyLongDate }} | @@ -400,8 +443,24 @@ | ||
+ +
+
+
+ Login Tokens
+
+
+
diff --git a/src/views/profile.js b/src/views/profile.js
index 295b89495..8d43e6fc3 100644
--- a/src/views/profile.js
+++ b/src/views/profile.js
@@ -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();
});
+
+
-
You have {{ tokens.webadminTokens.length }} active web token(s) and {{ tokens.cliTokens.length }}.
+-