From f2a5aa01798423e700000a48053296aa01ced8c1 Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Sat, 21 Oct 2023 22:48:54 +0200 Subject: [PATCH] maybe better permissions check --- _define.php | 11 ++++++----- src/My.php | 7 +++++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/_define.php b/_define.php index 24181b4..97a663c 100644 --- a/_define.php +++ b/_define.php @@ -19,10 +19,11 @@ $this->registerModule( 'Jean-Christian Denis', '2023.10.19', [ - 'requires' => [['core', '2.28']], - 'type' => 'plugin', - 'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues', - 'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md', - 'repository' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/raw/branch/master/dcstore.xml', + 'requires' => [['core', '2.28']], + 'permissions' => 'My', + 'type' => 'plugin', + 'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues', + 'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md', + 'repository' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/raw/branch/master/dcstore.xml', ] ); diff --git a/src/My.php b/src/My.php index ff24bb9..39ba9f3 100644 --- a/src/My.php +++ b/src/My.php @@ -36,7 +36,10 @@ class My extends MyPlugin public static function checkCustomContext(int $context): ?bool { - // Only backend and super admin - return $context === self::INSTALL ? null : App::task()->checkContext('BACKEND') && App::auth()->isSuperAdmin(); + // Limit to super admin + return match ($context) { + self::MODULE => App::auth()->isSuperAdmin(), + default => null, + }; } }