diff options
author | Morris Jobke <hey@morrisjobke.de> | 2018-02-26 17:50:21 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-26 17:50:21 +0100 |
commit | a60d7a8563f6f9e8047ac187e8f96f09f6dfa844 (patch) | |
tree | ed188b5a10bd2006b3ca97bea0e6e5502eb49192 /lib | |
parent | 67a76b00e8e05dbed5acaa8f9dc6a7d28065e6aa (diff) | |
parent | cf35c4b03ab7bd73cc5e9a26d88a0c61731d4b6e (diff) | |
download | nextcloud-server-a60d7a8563f6f9e8047ac187e8f96f09f6dfa844.tar.gz nextcloud-server-a60d7a8563f6f9e8047ac187e8f96f09f6dfa844.zip |
Merge pull request #8541 from nextcloud/translate-permission-error-page
Provide translated error message for permission error
Diffstat (limited to 'lib')
3 files changed, 12 insertions, 4 deletions
diff --git a/lib/private/AppFramework/DependencyInjection/DIContainer.php b/lib/private/AppFramework/DependencyInjection/DIContainer.php index 44c268bdea6..4dcb94a1d33 100644 --- a/lib/private/AppFramework/DependencyInjection/DIContainer.php +++ b/lib/private/AppFramework/DependencyInjection/DIContainer.php @@ -219,7 +219,8 @@ class DIContainer extends SimpleContainer implements IAppContainer { $server->getContentSecurityPolicyManager(), $server->getCsrfTokenManager(), $server->getContentSecurityPolicyNonceManager(), - $server->getAppManager() + $server->getAppManager(), + $server->getL10N('lib') ); }); diff --git a/lib/private/AppFramework/Middleware/Security/Exceptions/NotAdminException.php b/lib/private/AppFramework/Middleware/Security/Exceptions/NotAdminException.php index ca8a2c89416..cd73c81e18a 100644 --- a/lib/private/AppFramework/Middleware/Security/Exceptions/NotAdminException.php +++ b/lib/private/AppFramework/Middleware/Security/Exceptions/NotAdminException.php @@ -1,4 +1,5 @@ <?php +declare(strict_types=1); /** * @copyright Copyright (c) 2016, ownCloud, Inc. * @@ -35,7 +36,7 @@ use OCP\AppFramework\Http; * @package OC\AppFramework\Middleware\Security\Exceptions */ class NotAdminException extends SecurityException { - public function __construct($message = 'Logged in user must be an admin') { + public function __construct(string $message) { parent::__construct($message, Http::STATUS_FORBIDDEN); } } diff --git a/lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php b/lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php index f45c8f8726c..bb3083c835c 100644 --- a/lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php +++ b/lib/private/AppFramework/Middleware/Security/SecurityMiddleware.php @@ -48,6 +48,7 @@ use OCP\AppFramework\Middleware; use OCP\AppFramework\Http\Response; use OCP\AppFramework\Http\JSONResponse; use OCP\AppFramework\OCSController; +use OCP\IL10N; use OCP\INavigationManager; use OCP\IURLGenerator; use OCP\IRequest; @@ -87,6 +88,8 @@ class SecurityMiddleware extends Middleware { private $cspNonceManager; /** @var IAppManager */ private $appManager; + /** @var IL10N */ + private $l10n; /** * @param IRequest $request @@ -101,6 +104,7 @@ class SecurityMiddleware extends Middleware { * @param CSRFTokenManager $csrfTokenManager * @param ContentSecurityPolicyNonceManager $cspNonceManager * @param IAppManager $appManager + * @param IL10N $l10n */ public function __construct(IRequest $request, ControllerMethodReflector $reflector, @@ -113,7 +117,8 @@ class SecurityMiddleware extends Middleware { ContentSecurityPolicyManager $contentSecurityPolicyManager, CsrfTokenManager $csrfTokenManager, ContentSecurityPolicyNonceManager $cspNonceManager, - IAppManager $appManager + IAppManager $appManager, + IL10N $l10n ) { $this->navigationManager = $navigationManager; $this->request = $request; @@ -127,6 +132,7 @@ class SecurityMiddleware extends Middleware { $this->csrfTokenManager = $csrfTokenManager; $this->cspNonceManager = $cspNonceManager; $this->appManager = $appManager; + $this->l10n = $l10n; } /** @@ -152,7 +158,7 @@ class SecurityMiddleware extends Middleware { if(!$this->reflector->hasAnnotation('NoAdminRequired')) { if(!$this->isAdminUser) { - throw new NotAdminException(); + throw new NotAdminException($this->l10n->t('Logged in user must be an admin')); } } } |