verbb / patrol

Easy Maintenance Mode and Smart HTTPS Routing for Craft CMS
MIT License
29 stars 8 forks source link

Enabling Patrol functions in "production" environment #18

Closed sam327 closed 4 years ago

sam327 commented 5 years ago

I'd really like to be able to use the maintenance mode toggle in production.

I assume it's being blocked by the setting in config/general.php, where production has 'allowAdminChanges' => false, in it.

Any way to enable some of patrol's settings settings without turning that particular setting to true?

selvinortiz commented 5 years ago

@sam327 You want to enable production via the CP by toggling the maintenance mode lightswitch but you believe that allowAdminChanges => false in your config is preventing you, correct?

I'm not sure that's the case, it could be Patrol preventing your from doing that if that particular setting is being handled in the patrol.php config file, either in the * or production environment.

Can you share your patrol.php config file in /config?

sam327 commented 5 years ago

Right, that's the meat of it. When I hit the Patrol link in the Craft sidebar, I get the 'no admin changes allowed' error (as one might expect). Where I'd really like to be able to toggle that maintenance mode on and off. Long story short, I want a client/admin to be able to put the site in maintenance mode if they break something and can't fix it themselves.

My config/patrol.php is very bare bones.

<?php
return [
    '*' => [
        'primaryDomain' => "www.mywebsite.com",
        'redirectStatusCode' => 302,
        'sslRoutingBaseUrl' => "https://www.mywebsite.com",
    ]
];

After I saw your note, I tried deleting that file entirely, and still had the problem.

And my config/general.php is pretty close to the default craft one.

<?php
return [
    '*' => [
        'defaultWeekStartDay' => 0,
        'omitScriptNameInUrls' => true,
        'cpTrigger' => 'admin',
        'securityKey' => getenv('SECURITY_KEY'),
        'addTrailingSlashesToUrls' => true,
        'limitAutoSlugsToAscii' => true,
        'convertFilenamesToAscii' => true,
    ],
    'dev' => [
        'devMode' => true,
    ],
    'staging' => [
        'devMode' => false,
        'allowAdminChanges' => false,
    ],
    'production' => [
        'devMode' => false,
        'allowAdminChanges' => false,
    ],
];
selvinortiz commented 4 years ago

@sam327 It's been a while since we started this thread but I wanted to follow up and see if you figured out a workaround.

I feel like because Patrol is such a developer centric plugin, you have to make the choice to manage settings in the CP or through the file and whether or not admin changes are allowed in prod

sam327 commented 4 years ago

Just saw your note - github notices started going into my spam bin.

Anyhow, my workaround turned into just workflow fixes / documentation.

Left allowAdminChanges set as true. Instead of having users in one group (plus a one admin), I broke them up into a couple groups, so only some have access to Patrol. It's working out mostly fine. Documentation and flow-charts of what-ifs seem to be working out fine.