1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SilverStripe\LoginForms; |
4
|
|
|
|
5
|
|
|
use SilverStripe\View\SSViewer; |
|
|
|
|
6
|
|
|
use SilverStripe\Core\Extension; |
|
|
|
|
7
|
|
|
use SilverStripe\Security\Security; |
|
|
|
|
8
|
|
|
use SilverStripe\Core\Config\Config; |
|
|
|
|
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Applies to the {@see Security} controller in order to detect requests for actions related to |
12
|
|
|
* the log in process or other such credential management (such as the forgot password flow). |
13
|
|
|
* This is in order to replace the set {@see SSViewer} theme list with a controlled set in order |
14
|
|
|
* to always show a consistent interface that relates more to the CMS than the website it is |
15
|
|
|
* loading on. |
16
|
|
|
* Particular actions can be set to be ignored by including them in the `excluded_actions` list |
17
|
|
|
* defined in yml _config for this class. By default all allowed actions on the Security controller |
18
|
|
|
* excepting `index` and `ping` will have the new theme set applied. |
19
|
|
|
*/ |
20
|
|
|
class EnablerExtension extends Extension |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* @var array themes to use for log in page and related actions. |
24
|
|
|
* @config |
25
|
|
|
*/ |
26
|
|
|
private static $login_themes = []; |
|
|
|
|
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Aids in preventing themes from being overridden in the case of delegating handlers |
30
|
|
|
* e.g. if an extension adds a route that should not be styled by login-forms, this config |
31
|
|
|
* setting can be used to prevent the otherwise blanket override applying to all actions. |
32
|
|
|
* @var array {@see Security} actions that should not have the custom themes applied |
33
|
|
|
* @config |
34
|
|
|
*/ |
35
|
|
|
private static $excluded_actions = [ |
|
|
|
|
36
|
|
|
'index', |
37
|
|
|
'ping', |
38
|
|
|
]; |
39
|
|
|
|
40
|
|
|
public function beforeCallActionHandler() |
41
|
|
|
{ |
42
|
|
|
$config = Config::inst(); |
43
|
|
|
/** @var Security $owner */ |
44
|
|
|
$owner = $this->getOwner(); |
45
|
|
|
$action = $owner->getAction(); |
46
|
|
|
$allowedActions = $config->get(Security::class, 'allowed_actions'); |
47
|
|
|
$excludedActions = $config->get(self::class, 'excluded_actions'); |
48
|
|
|
$themeActions = array_diff($allowedActions, $excludedActions); |
49
|
|
|
if (in_array($action, $themeActions)) { |
50
|
|
|
SSViewer::set_themes($config->get(self::class, 'login_themes')); |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths