From 12a725f704b02b9494e18188848ce9abffd5a912 Mon Sep 17 00:00:00 2001 From: SteDev2 Date: Wed, 20 Nov 2024 15:50:36 +0100 Subject: [PATCH] Add confirmation before rotate client secret --- .../clientsecret/clientsecret.component.js | 42 +++++++++++++------ 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/iam-login-service/src/main/webapp/resources/iam/apps/dashboard-app/components/clients/client/clientsecret/clientsecret.component.js b/iam-login-service/src/main/webapp/resources/iam/apps/dashboard-app/components/clients/client/clientsecret/clientsecret.component.js index b78864b54..42ec45c4e 100644 --- a/iam-login-service/src/main/webapp/resources/iam/apps/dashboard-app/components/clients/client/clientsecret/clientsecret.component.js +++ b/iam-login-service/src/main/webapp/resources/iam/apps/dashboard-app/components/clients/client/clientsecret/clientsecret.component.js @@ -16,7 +16,7 @@ (function () { 'use strict'; - function ClientSecretController(toaster, ClientsService) { + function ClientSecretController(ModalService, toaster, ClientsService) { var self = this; self.showSecret = false; @@ -71,18 +71,34 @@ } function rotateClientSecret() { - ClientsService.rotateClientSecret(self.client.client_id).then(res => { - self.client = res; - toaster.pop({ - type: 'success', - body: 'Secret rotated for client ' + self.client.client_name - }); - }).catch(res => { - toaster.pop({ - type: 'error', - body: 'Could not rotate secret for client ' + self.client.client_name + + var modalOptions = { + closeButtonText: 'Cancel', + actionButtonText: 'Confirm Change', + headerText: 'Regenerate Client Secret', + bodyText: + `Are you sure you want to change the secret of this client: ` + self.client.client_name+ ` ?` + }; + + ModalService.showModal({}, modalOptions) + .then( + function() { + ClientsService.rotateClientSecret(self.client.client_id).then(res => { + self.client = res; + toaster.pop({ + type: 'success', + body: 'Secret rotated for client ' + self.client.client_name + }); + }).catch(res => { + toaster.pop({ + type: 'error', + body: 'Could not rotate secret for client ' + self.client.client_name + }); + }); + } + ).catch(function(error) { + console.info("Cancel Regenerate Client Secret"); }); - }); } self.$onInit = function () { @@ -104,7 +120,7 @@ newClient: "<", limited: '@' }, - controller: ['toaster', 'ClientsService', ClientSecretController], + controller: ['ModalService', 'toaster', 'ClientsService', ClientSecretController], controllerAs: '$ctrl' }; }