From cf35c4b03ab7bd73cc5e9a26d88a0c61731d4b6e Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Mon, 26 Feb 2018 15:32:17 +0100 Subject: Provide translated error message for permission error Signed-off-by: Morris Jobke --- settings/Middleware/SubadminMiddleware.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'settings/Middleware') diff --git a/settings/Middleware/SubadminMiddleware.php b/settings/Middleware/SubadminMiddleware.php index 9914d65af02..5df17cb13b4 100644 --- a/settings/Middleware/SubadminMiddleware.php +++ b/settings/Middleware/SubadminMiddleware.php @@ -30,6 +30,7 @@ use OC\AppFramework\Utility\ControllerMethodReflector; use OCP\AppFramework\Controller; use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Middleware; +use OCP\IL10N; /** * Verifies whether an user has at least subadmin rights. @@ -42,15 +43,20 @@ class SubadminMiddleware extends Middleware { protected $isSubAdmin; /** @var ControllerMethodReflector */ protected $reflector; + /** @var IL10N */ + private $l10n; /** * @param ControllerMethodReflector $reflector * @param bool $isSubAdmin + * @param IL10N $l10n */ public function __construct(ControllerMethodReflector $reflector, - $isSubAdmin) { + $isSubAdmin, + IL10N $l10n) { $this->reflector = $reflector; $this->isSubAdmin = $isSubAdmin; + $this->l10n = $l10n; } /** @@ -62,7 +68,7 @@ class SubadminMiddleware extends Middleware { public function beforeController($controller, $methodName) { if(!$this->reflector->hasAnnotation('NoSubadminRequired')) { if(!$this->isSubAdmin) { - throw new NotAdminException('Logged in user must be a subadmin'); + throw new NotAdminException($this->l10n->t('Logged in user must be a subadmin')); } } } -- cgit v1.2.3