X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=blobdiff_plain;f=img_auth.php;h=1434125af991df0cdff797465ca37c894796b923;hp=ba4ed748348235de108f382d4cee24dc906d2d10;hb=dfec83932fd38a9086eb5a2e212889ad00f35b0e;hpb=447574ceb746c2f4026a8bf77632bdc4604314bb diff --git a/img_auth.php b/img_auth.php index ba4ed74834..1434125af9 100644 --- a/img_auth.php +++ b/img_auth.php @@ -79,6 +79,8 @@ function wfImageAuthMain() { return; } + $user = RequestContext::getMain()->getUser(); + // Various extensions may have their own backends that need access. // Check if there is a special backend and storage base path for this file. foreach ( $wgImgAuthUrlPathMap as $prefix => $storageDir ) { @@ -87,7 +89,7 @@ function wfImageAuthMain() { $be = FileBackendGroup::singleton()->backendFromPath( $storageDir ); $filename = $storageDir . substr( $path, strlen( $prefix ) ); // strip prefix // Check basic user authorization - if ( !RequestContext::getMain()->getUser()->isAllowed( 'read' ) ) { + if ( !$user->isAllowed( 'read' ) ) { wfForbidden( 'img-auth-accessdenied', 'img-auth-noread', $path ); return; } @@ -157,7 +159,9 @@ function wfImageAuthMain() { // Check user authorization for this title // Checks Whitelist too - if ( !$title->userCan( 'read' ) ) { + $permissionManager = \MediaWiki\MediaWikiServices::getInstance()->getPermissionManager(); + + if ( !$permissionManager->userCan( 'read', $user, $title ) ) { wfForbidden( 'img-auth-accessdenied', 'img-auth-noread', $name ); return; }