move tokens entirely into token page
This commit is contained in:
+1
-57
@@ -12,7 +12,6 @@ angular.module('Application').controller('ProfileController', ['$scope', '$locat
|
||||
$scope.webadminClient = {};
|
||||
$scope.apiClient = {};
|
||||
$scope.cliClient = {};
|
||||
$scope.showApiTokens = !!$location.search().tokens;
|
||||
|
||||
$scope.twoFactorAuthentication = {
|
||||
busy: false,
|
||||
@@ -298,61 +297,6 @@ angular.module('Application').controller('ProfileController', ['$scope', '$locat
|
||||
}
|
||||
};
|
||||
|
||||
$scope.tokenAdd = {
|
||||
token: {},
|
||||
tokenName: '',
|
||||
busy: false,
|
||||
error: {},
|
||||
|
||||
reset: function () {
|
||||
$scope.tokenAdd.busy = false;
|
||||
$scope.tokenAdd.token = {};
|
||||
$scope.tokenAdd.error.tokenName = null;
|
||||
$scope.tokenAdd.tokenName = '';
|
||||
|
||||
$scope.tokenAddForm.$setUntouched();
|
||||
$scope.tokenAddForm.$setPristine();
|
||||
},
|
||||
|
||||
show: function () {
|
||||
$scope.tokenAdd.reset();
|
||||
$('#tokenAddModal').modal('show');
|
||||
},
|
||||
|
||||
submit: function (client) {
|
||||
$scope.tokenAdd.busy = true;
|
||||
$scope.tokenAdd.token = {};
|
||||
|
||||
var expiresAt = Date.now() + 100 * 365 * 24 * 60 * 60 * 1000; // ~100 years from now
|
||||
|
||||
Client.createTokenByClientId(client.id, '*' /* scope */, expiresAt, $scope.tokenAdd.tokenName, function (error, result) {
|
||||
if (error) {
|
||||
if (error.statusCode === 400) {
|
||||
$scope.tokenAdd.error.tokenName = 'Invalid token name';
|
||||
$scope.tokenAddForm.tokenName.$setPristine();
|
||||
$('#inputTokenAddName').focus();
|
||||
} else {
|
||||
console.error('Unable to create token.', error);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
$scope.tokenAdd.busy = false;
|
||||
$scope.tokenAdd.token = result;
|
||||
|
||||
refreshClientTokens(client);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
$scope.removeToken = function (client, token) {
|
||||
Client.delToken(client.id, token.id, function (error) {
|
||||
if (error) console.error(error);
|
||||
|
||||
refreshClientTokens(client);
|
||||
});
|
||||
};
|
||||
|
||||
function revokeTokensByClient(client, callback) {
|
||||
Client.delTokensByClientId(client.id, function (error) {
|
||||
if (error) console.error(error);
|
||||
@@ -399,7 +343,7 @@ angular.module('Application').controller('ProfileController', ['$scope', '$locat
|
||||
});
|
||||
|
||||
// setup all the dialog focus handling
|
||||
['passwordChangeModal', 'emailChangeModal', 'fallbackEmailChangeModal', 'displayNameChangeModal', 'twoFactorAuthenticationEnableModal', 'twoFactorAuthenticationDisableModal', 'tokenAddModal'].forEach(function (id) {
|
||||
['passwordChangeModal', '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