Skip to content

Commit 7b4e423

Browse files
authored
Merge pull request #8835 from ProcessMaker/FOUR-31336
FOUR-31336 | Change on clients adding modal for plainSecret
2 parents 1b4c616 + 83fffed commit 7b4e423

6 files changed

Lines changed: 64 additions & 43 deletions

File tree

ProcessMaker/Http/Controllers/Auth/ClientController.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ public function store(Request $request)
6565
);
6666
}
6767

68-
$client->makeVisible('secret');
6968
AuthClientCreated::dispatch($client->getAttributes());
7069

7170
return new AuthClientResource($client);

ProcessMaker/Http/Resources/AuthClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function toArray($request)
2626
return [
2727
'id' => $this->id,
2828
'name' => $this->name,
29-
'secret' => $this->secret,
29+
'secret' => $this->plainSecret,
3030
'redirect' => $this->redirect,
3131
'revoked' => $this->revoked,
3232
'types' => $types,

resources/js/admin/auth-clients/components/AuthClientsListing.vue

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,6 @@
3333
:divider="true"
3434
/>
3535
</template>
36-
<template slot="secret" slot-scope="props">
37-
<b-btn
38-
variant="link"
39-
class="copylink"
40-
@click="copySecret(props.rowData.secret)"
41-
v-b-tooltip.hover
42-
:title="$t('Copy Client Secret To Clipboard')"
43-
v-uni-aria-describedby="props.rowData.id.toString()"
44-
>
45-
<i class="fas fa-clipboard fa-lg fa-fw"></i>
46-
</b-btn>
47-
{{ props.rowData.secret.substr(0, 10) }}...
48-
</template>
4936
</vuetable>
5037
<pagination
5138
:single="$t('Auth Client')"
@@ -55,7 +42,6 @@
5542
@vuetable-pagination:change-page="onPageChange"
5643
ref="pagination"
5744
></pagination>
58-
<textarea class="copytext" ref="copytext"></textarea>
5945
</div>
6046
</div>
6147
</template>
@@ -73,7 +59,6 @@ export default {
7359
props: ["filter", "permission"],
7460
data() {
7561
return {
76-
copytext: "",
7762
sortOrder: [
7863
{
7964
field: "name",
@@ -101,10 +86,6 @@ export default {
10186
return val.substr(0, 20) + "...";
10287
},
10388
},
104-
{
105-
title: () => this.$t("Client Secret"),
106-
name: "__slot:secret",
107-
},
10889
{
10990
name: "__slot:actions",
11091
title: "",
@@ -129,8 +110,7 @@ export default {
129110
data = data.filter((item) => {
130111
return (
131112
item.name.toLowerCase().indexOf(this.filter.toLowerCase()) > -1 ||
132-
item.redirect.toLowerCase().indexOf(this.filter.toLowerCase()) > -1 ||
133-
item.secret.toLowerCase().indexOf(this.filter.toLowerCase()) > -1
113+
item.redirect.toLowerCase().indexOf(this.filter.toLowerCase()) > -1
134114
);
135115
});
136116
}
@@ -184,11 +164,6 @@ export default {
184164
}
185165
this.fetch();
186166
},
187-
copySecret(secret) {
188-
this.$refs.copytext.value = secret;
189-
this.$refs.copytext.select();
190-
document.execCommand("copy");
191-
},
192167
onNavigate(action, data) {
193168
switch (action.value) {
194169
case 'edit-item':
@@ -223,15 +198,3 @@ export default {
223198
},
224199
};
225200
</script>
226-
227-
<style>
228-
.copytext {
229-
position: absolute;
230-
left: -1000px;
231-
top: -1000px;
232-
}
233-
234-
.copylink {
235-
padding: 0;
236-
}
237-
</style>

resources/lang/en.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,7 @@
474474
"Copy Control": "Copy Control",
475475
"Copy Element": "Copy Element",
476476
"Copy link": "Copy link",
477+
"Copy Secret To Clipboard": "Copy Secret To Clipboard",
477478
"Copy Screen": "Copy Screen",
478479
"Copy Script": "Copy Script",
479480
"Copy this URL into your Atlassian authorization settings": "Copy this URL into your Atlassian authorization settings",
@@ -498,6 +499,7 @@
498499
"Create an Inbox Rule Now": "Create an Inbox Rule Now",
499500
"Create Auth Clients": "Create Auth Clients",
500501
"Create AuthClients": "Create Auth-Clients",
502+
"Create Auth-Client": "Create Auth-Client",
501503
"Create Bundle": "Create Bundle",
502504
"Create Categories": "Create Categories",
503505
"Create Category": "Create Category",
@@ -2361,6 +2363,7 @@
23612363
"This file is password protected. Enter the password below to continue with the import.": "This file is password protected. Enter the password below to continue with the import.",
23622364
"This is a Beta version and when using Quickfill, it may replace the pre-filled information in the form.": "This is a Beta version and when using Quickfill, it may replace the pre-filled information in the form.",
23632365
"This is an AI feature and can provide inaccurate or biased responses.": "This is an AI feature and can provide inaccurate or biased responses.",
2366+
"This is the only time you will be able to view the client secret. Keep it in a safe place.": "This is the only time you will be able to view the client secret. Keep it in a safe place.",
23642367
"This is your security code: :code": "This is your security code: :code",
23652368
"This may cause validation errors during submission.": "This may cause validation errors during submission.",
23662369
"This must be valid JSON": "This must be valid JSON",

resources/lang/es.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,7 @@
455455
"Copy Control": "Control de copia",
456456
"Copy Element": "Copiar elemento",
457457
"Copy link": "Copiar enlace",
458+
"Copy Secret To Clipboard": "Copiar secreto al portapapeles",
458459
"Copy Screen": "Copiar pantalla",
459460
"Copy Script": "Copiar script",
460461
"Copy this URL into your Atlassian authorization settings": "Copie esta URL en su configuración de autorización de Atlassian",
@@ -474,6 +475,7 @@
474475
"Create a new Process": "Crea un nuevo Proceso",
475476
"Create a Project": "Crea un Proyecto",
476477
"Create An Auth-Client": "Crear un cliente autenticado",
478+
"Create Auth-Client": "Crear cliente autenticado",
477479
"Create an Inbox Rule Now": "Crea una Regla de Bandeja de Entrada Ahora",
478480
"Create Auth Clients": "Crear clientes de autenticación",
479481
"Create AuthClients": "Crear clientes autenticados",
@@ -2293,6 +2295,7 @@
22932295
"This file is password protected. Enter the password below to continue with the import.": "Este archivo está protegido con contraseña. Ingrese la contraseña a continuación para continuar con la importación.",
22942296
"This is a Beta version and when using Quickfill, it may replace the pre-filled information in the form.": "Esta es una versión Beta y al usar Quickfill, puede reemplazar la información previamente llenada en el formulario.",
22952297
"This is an AI feature and can provide inaccurate or biased responses.": "Esta es una función de IA y puede proporcionar respuestas inexactas o sesgadas.",
2298+
"This is the only time you will be able to view the client secret. Keep it in a safe place.": "Esta es la única vez que podrás ver el secreto del cliente. Manténgalo en un lugar seguro.",
22962299
"This is your security code: :code": "This is your security code: :code",
22972300
"This may cause validation errors during submission.": "Esto puede causar errores de validación durante la presentación.",
22982301
"This must be valid JSON": "Este debe ser un JSON válido",

resources/views/admin/auth-clients/index.blade.php

Lines changed: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,26 @@
4040
</div>
4141
</b-form-checkbox-group>
4242
</pm-modal>
43+
<pm-modal ref="secretModal" id="secretModal" :title="secretTitle" style="display: none;"
44+
:set-custom-buttons="true"
45+
:custom-buttons="customModalButtons"
46+
@close="hideSecretModal">
47+
<div class="form-group">
48+
<label for="secret">{{__('Secret')}}</label>
49+
<div class="input-group">
50+
<input readonly disabled type="text" class="form-control" id="secret" v-model="secret">
51+
<div class="input-group-append">
52+
<button type="button" class="btn btn-primary" @click="copySecret(secret)" v-b-tooltip.hover :title="$t('Copy Secret To Clipboard')">
53+
<i class="fa-lg fas fa-copy" aria-hidden="true"></i>
54+
</button>
55+
</div>
56+
</div>
57+
</div>
58+
<div class="tw-flex tw-items-start tw-gap-3 tw-p-3 tw-mt-3 tw-rounded-lg tw-border tw-border-amber-300 tw-bg-amber-50 tw-text-amber-900" role="alert">
59+
<i class="fas fa-exclamation-triangle tw-text-amber-500 tw-mt-0.5 tw-shrink-0" aria-hidden="true"></i>
60+
<p class="tw-text-sm tw-m-0">{{ __('This is the only time you will be able to view the client secret. Keep it in a safe place.') }}</p>
61+
</div>
62+
</pm-modal>
4363

4464
<div class="px-3 page-content">
4565
<div id="search-bar" class="search mb-3" vcloak>
@@ -66,7 +86,6 @@
6686
<auth-clients-listing ref="authClientList" :permission="{{ \Auth::user()->hasPermissionsFor('auth_clients') }}" :filter="filter" @edit="edit"/>
6787
</div>
6888
</div>
69-
7089
</div>
7190
@endsection
7291

@@ -88,8 +107,12 @@
88107
errors: null,
89108
disabled: false,
90109
title:'',
110+
secretTitle:'',
111+
customModalButtons: [],
112+
secret: "",
91113
},
92114
beforeMount() {
115+
this.initCustomModalButtons();
93116
this.resetValues();
94117
},
95118
methods: {
@@ -120,8 +143,14 @@
120143
data: this.authClient,
121144
}).then(response => {
122145
this.$refs.createEditAuthClient.hide();
123-
this.$refs.authClientList.fetch();
124146
this.loading = false;
147+
if (response.data.secret) {
148+
this.secret = response.data.secret
149+
this.$refs.secretModal.show();
150+
}
151+
else {
152+
this.$refs.authClientList.fetch();
153+
}
125154
ProcessMaker.alert(this.$t("The auth client was ") + verb + ".", this.$t("success"))
126155
}).catch(error => {
127156
this.disabled = false;
@@ -130,6 +159,7 @@
130159
},
131160
resetValues() {
132161
this.title = this.$t('Create Auth-Client')
162+
this.secretTitle = this.$t('Copy Secret To Clipboard')
133163
this.authClient = {
134164
id: null,
135165
name: "",
@@ -143,12 +173,35 @@
143173
types: null
144174
};
145175
this.disabled = false;
176+
this.initCustomModalButtons();
146177
},
147178
edit(item) {
148179
this.title = this.$t('Edit Auth Client');
149180
this.authClient = item;
150181
this.$refs.createEditAuthClient.show();
151-
}
182+
},
183+
initCustomModalButtons() {
184+
this.customModalButtons = [
185+
{
186+
content: "Close",
187+
action: "close",
188+
variant: "secondary",
189+
disabled: false,
190+
hidden: false,
191+
},
192+
];
193+
},
194+
hideSecretModal() {
195+
this.$refs.secretModal.hide();
196+
this.$refs.authClientList.fetch();
197+
},
198+
copySecret(secret) {
199+
navigator.clipboard.writeText(secret).then(() => {
200+
ProcessMaker.alert(this.$t("Secret copied to clipboard."), "success");
201+
}, () => {
202+
ProcessMaker.alert(this.$t("Secret not copied to clipboard."), "danger");
203+
});
204+
},
152205
},
153206
})
154207
</script>

0 commit comments

Comments
 (0)