aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan-Hendrik Willms <tleilax+studip@gmail.com>2025-10-23 11:01:53 +0200
committerJan-Hendrik Willms <tleilax+studip@gmail.com>2025-10-23 11:01:53 +0200
commit157a8f575b1ae5dd7248a5af6249d17c81c47ad3 (patch)
tree9c06d96b892f9218ff416d78113e148cebcbfc46
parente1f646b588b1802d2510f3fe87a7605f881db6ae (diff)
use messagebox in body for created oauth2 client credentials, fixes #5958
Closes #5958 Merge request studip/studip!4553
-rw-r--r--app/controllers/admin/oauth2.php2
-rw-r--r--app/controllers/api/oauth2/clients.php37
-rw-r--r--app/views/admin/oauth2/_notices.php6
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<string, mixed>
+ * @param array<string, mixed> $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 <em lang="en"> client_id </em> lautet: <pre>%s</pre>'), $client['id']),
- sprintf(_('Das <em lang="en"> client_secret </em> lautet: <pre>%s</pre>'), $client->plainsecret),
- _(
- 'Notieren Sie sich bitte das <em lang="en"> client_secret </em>. Es wird Ihnen nur <strong> dieses eine Mal </strong> angezeigt.'
- ),
- ]);
+ $this->flash['oauth2-message'] = MessageBox::warning(
+ _('Der OAuth2-Client wurde erstellt.'),
+ [
+ sprintf(
+ _('Die <em lang="en"> client_id </em> lautet: <pre>%s</pre>'),
+ htmlReady($client['id'])
+ ),
+ sprintf(
+ _('Das <em lang="en"> client_secret </em> lautet: <pre>%s</pre>'),
+ htmlReady($client->plainsecret)
+ ),
+ _('Notieren Sie sich bitte das <em lang="en"> client_secret </em>. Es wird Ihnen nur <strong> dieses eine Mal </strong> angezeigt.'),
+ ]
+ );
} else {
- PageLayout::postSuccess(_('Der OAuth2-Client wurde erstellt.'), [
- sprintf(_('Die <em lang="en"> client_id </em> lautet: <pre>%s</pre>'), $client['id']),
- ]);
+ $this->flash['oauth2-message'] = MessageBox::success(
+ _('Der OAuth2-Client wurde erstellt.'),
+ [
+ sprintf(
+ _('Die <em lang="en"> client_id </em> lautet: <pre>%s</pre>'),
+ 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
*/
?>
-<? if (!isset($clients) || !count($clients)) { ?>
+<?= $message ?>
+<? if (!isset($clients) || count($clients) === 0): ?>
<?= MessageBox::info(
_('Es wurde noch kein OAuth2-Client erstellt.') .
'<br/>' .
@@ -13,4 +15,4 @@
$controller->link_for('api/oauth2/clients/add')
)
) ?>
-<? } ?>
+<? endif; ?>