From 157a8f575b1ae5dd7248a5af6249d17c81c47ad3 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms Date: Thu, 23 Oct 2025 11:01:53 +0200 Subject: use messagebox in body for created oauth2 client credentials, fixes #5958 Closes #5958 Merge request studip/studip!4553 --- app/controllers/admin/oauth2.php | 2 ++ app/controllers/api/oauth2/clients.php | 37 +++++++++++++++++++++++----------- app/views/admin/oauth2/_notices.php | 6 ++++-- 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/app/controllers/admin/oauth2.php b/app/controllers/admin/oauth2.php index ae4f5f9..3fcd62d 100644 --- a/app/controllers/admin/oauth2.php +++ b/app/controllers/admin/oauth2.php @@ -42,5 +42,7 @@ class Admin_Oauth2Controller extends AuthenticatedController { $this->setup = $this->container->get(SetupInformation::class); $this->clients = Client::findBySql('1 ORDER BY chdate DESC'); + + $this->message = $this->flash['oauth2-message'] ?? ''; } } diff --git a/app/controllers/api/oauth2/clients.php b/app/controllers/api/oauth2/clients.php index c16b67d..edf1170 100644 --- a/app/controllers/api/oauth2/clients.php +++ b/app/controllers/api/oauth2/clients.php @@ -29,7 +29,7 @@ class Api_Oauth2_ClientsController extends AuthenticatedController $this->redirect('admin/oauth2'); - list($valid, $data, $errors) = $this->validateCreateClientRequest(); + [$valid, $data, $errors] = $this->validateCreateClientRequest(); if (!$valid) { PageLayout::postError(_('Das Erstellen eines OAuth2-Clients war nicht erfolgreich.'), $errors); @@ -55,7 +55,7 @@ class Api_Oauth2_ClientsController extends AuthenticatedController /** * Create a authorization code client. * - * @param array + * @param array $data */ private function createAuthCodeClient(array $data): Client { @@ -76,17 +76,30 @@ class Api_Oauth2_ClientsController extends AuthenticatedController private function outputClientCredentials(Client $client): void { if ($client->confidential()) { - PageLayout::postWarning(_('Der OAuth2-Client wurde erstellt.'), [ - sprintf(_('Die client_id lautet:
%s
'), $client['id']), - sprintf(_('Das client_secret lautet:
%s
'), $client->plainsecret), - _( - 'Notieren Sie sich bitte das client_secret . Es wird Ihnen nur dieses eine Mal angezeigt.' - ), - ]); + $this->flash['oauth2-message'] = MessageBox::warning( + _('Der OAuth2-Client wurde erstellt.'), + [ + sprintf( + _('Die client_id lautet:
%s
'), + htmlReady($client['id']) + ), + sprintf( + _('Das client_secret lautet:
%s
'), + htmlReady($client->plainsecret) + ), + _('Notieren Sie sich bitte das client_secret . Es wird Ihnen nur dieses eine Mal angezeigt.'), + ] + ); } else { - PageLayout::postSuccess(_('Der OAuth2-Client wurde erstellt.'), [ - sprintf(_('Die client_id lautet:
%s
'), $client['id']), - ]); + $this->flash['oauth2-message'] = MessageBox::success( + _('Der OAuth2-Client wurde erstellt.'), + [ + sprintf( + _('Die client_id lautet:
%s
'), + htmlReady($client['id']) + ), + ] + ); } } diff --git a/app/views/admin/oauth2/_notices.php b/app/views/admin/oauth2/_notices.php index 6f26008..35b0be6 100644 --- a/app/views/admin/oauth2/_notices.php +++ b/app/views/admin/oauth2/_notices.php @@ -2,9 +2,11 @@ /** * @var Admin_Oauth2Controller $controller * @var Studip\OAuth2\Models\Client[] $clients + * @var string $message */ ?> - + + ' . @@ -13,4 +15,4 @@ $controller->link_for('api/oauth2/clients/add') ) ) ?> - + -- cgit v1.0