Change source of admin URL in getIsAdmin()

As per #394 
Change direct call to the AdminRootController config setting, using instead the admin_url() method on the class which provides detection via the Director rules, and the fallback to the config setting.
This commit is contained in:
DorsetDigital 2018-10-17 23:20:20 +01:00 committed by GitHub
parent 19f0162265
commit 1e458ef03d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -62,7 +62,7 @@ class InitStateMiddleware implements HTTPMiddleware
public function getIsAdmin(HTTPRequest $request)
{
$adminPaths = static::config()->get('admin_url_paths');
$adminPaths[] = AdminRootController::config()->get('url_base') . '/';
$adminPaths[] = AdminRootController::admin_url();
$currentPath = rtrim($request->getURL(), '/') . '/';
foreach ($adminPaths as $adminPath) {
if (substr($currentPath, 0, strlen($adminPath)) === $adminPath) {