@@ -7,106 +7,106 @@ |
||
7 | 7 | */ |
8 | 8 | class AdminSecurity extends Security |
9 | 9 | { |
10 | - /** |
|
11 | - * @var array |
|
12 | - */ |
|
13 | - private static $allowed_actions = array( |
|
14 | - 'passwordsent', |
|
15 | - 'ChangePasswordForm' |
|
16 | - ); |
|
10 | + /** |
|
11 | + * @var array |
|
12 | + */ |
|
13 | + private static $allowed_actions = array( |
|
14 | + 'passwordsent', |
|
15 | + 'ChangePasswordForm' |
|
16 | + ); |
|
17 | 17 | |
18 | - /** |
|
19 | - * Template thats used to render the pages. |
|
20 | - * |
|
21 | - * @config |
|
22 | - * @var string |
|
23 | - */ |
|
24 | - private static $template_main = 'AdminLogin'; |
|
18 | + /** |
|
19 | + * Template thats used to render the pages. |
|
20 | + * |
|
21 | + * @config |
|
22 | + * @var string |
|
23 | + */ |
|
24 | + private static $template_main = 'AdminLogin'; |
|
25 | 25 | |
26 | - /** |
|
27 | - * @return void |
|
28 | - */ |
|
29 | - public function init() |
|
30 | - { |
|
31 | - parent::init(); |
|
26 | + /** |
|
27 | + * @return void |
|
28 | + */ |
|
29 | + public function init() |
|
30 | + { |
|
31 | + parent::init(); |
|
32 | 32 | |
33 | - if (Config::inst()->get('IpAccess', 'enabled')) { |
|
34 | - $ipAccess = new IpAccess($this->getRequest()->getIP(), |
|
35 | - Config::inst()->get('IpAccess', 'allowed_ips')); |
|
36 | - if (!$ipAccess->hasAccess()) { |
|
37 | - $response = null; |
|
38 | - if (class_exists('ErrorPage', true)) { |
|
39 | - $response = ErrorPage::response_for(404); |
|
40 | - } |
|
41 | - $this->httpError(404, $response ? $response : 'The requested page could not be found.'); |
|
42 | - exit(); |
|
43 | - } |
|
44 | - } |
|
33 | + if (Config::inst()->get('IpAccess', 'enabled')) { |
|
34 | + $ipAccess = new IpAccess($this->getRequest()->getIP(), |
|
35 | + Config::inst()->get('IpAccess', 'allowed_ips')); |
|
36 | + if (!$ipAccess->hasAccess()) { |
|
37 | + $response = null; |
|
38 | + if (class_exists('ErrorPage', true)) { |
|
39 | + $response = ErrorPage::response_for(404); |
|
40 | + } |
|
41 | + $this->httpError(404, $response ? $response : 'The requested page could not be found.'); |
|
42 | + exit(); |
|
43 | + } |
|
44 | + } |
|
45 | 45 | |
46 | - if (Config::inst()->get('AdminLogin', 'UseTheme') !== true) { |
|
47 | - // this prevents loading frontend css and javscript files |
|
48 | - Object::useCustomClass('Page_Controller', 'AdminLoginPage_Controller'); |
|
49 | - Requirements::css('adminlogin/css/style.css'); |
|
50 | - } |
|
46 | + if (Config::inst()->get('AdminLogin', 'UseTheme') !== true) { |
|
47 | + // this prevents loading frontend css and javscript files |
|
48 | + Object::useCustomClass('Page_Controller', 'AdminLoginPage_Controller'); |
|
49 | + Requirements::css('adminlogin/css/style.css'); |
|
50 | + } |
|
51 | 51 | |
52 | - Object::useCustomClass('MemberLoginForm', 'AdminLoginForm'); |
|
53 | - } |
|
52 | + Object::useCustomClass('MemberLoginForm', 'AdminLoginForm'); |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * @param null $action |
|
57 | - * @return string |
|
58 | - */ |
|
59 | - public function Link($action = null) |
|
60 | - { |
|
61 | - return "AdminSecurity/$action"; |
|
62 | - } |
|
55 | + /** |
|
56 | + * @param null $action |
|
57 | + * @return string |
|
58 | + */ |
|
59 | + public function Link($action = null) |
|
60 | + { |
|
61 | + return "AdminSecurity/$action"; |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * @return string |
|
66 | - */ |
|
67 | - public static function isAdminLogin() |
|
68 | - { |
|
69 | - return strstr(self::getBackUrl(), '/admin/'); |
|
70 | - } |
|
64 | + /** |
|
65 | + * @return string |
|
66 | + */ |
|
67 | + public static function isAdminLogin() |
|
68 | + { |
|
69 | + return strstr(self::getBackUrl(), '/admin/'); |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * @return string |
|
74 | - */ |
|
75 | - public static function getBackUrl() |
|
76 | - { |
|
77 | - $request = Controller::curr()->getRequest(); |
|
78 | - if($url = $request->requestVar('BackURL')) { |
|
79 | - return $url; |
|
80 | - } |
|
81 | - return ''; |
|
82 | - } |
|
72 | + /** |
|
73 | + * @return string |
|
74 | + */ |
|
75 | + public static function getBackUrl() |
|
76 | + { |
|
77 | + $request = Controller::curr()->getRequest(); |
|
78 | + if($url = $request->requestVar('BackURL')) { |
|
79 | + return $url; |
|
80 | + } |
|
81 | + return ''; |
|
82 | + } |
|
83 | 83 | |
84 | - /** |
|
85 | - * @param SS_HTTPRequest $request |
|
86 | - * @return string |
|
87 | - */ |
|
88 | - public function passwordsent($request) |
|
89 | - { |
|
90 | - return parent::passwordsent($request); |
|
91 | - } |
|
84 | + /** |
|
85 | + * @param SS_HTTPRequest $request |
|
86 | + * @return string |
|
87 | + */ |
|
88 | + public function passwordsent($request) |
|
89 | + { |
|
90 | + return parent::passwordsent($request); |
|
91 | + } |
|
92 | 92 | |
93 | - /** |
|
94 | - * @see Security::getPasswordResetLink() |
|
95 | - * We overload this, so we can add the BackURL to the password resetlink |
|
96 | - */ |
|
97 | - public static function getPasswordResetLink($member, $autologinToken) |
|
98 | - { |
|
99 | - $autologinToken = urldecode($autologinToken); |
|
100 | - $selfControllerClass = __CLASS__; |
|
101 | - $selfController = new $selfControllerClass(); |
|
102 | - return $selfController->Link('changepassword') . "?m={$member->ID}&t=$autologinToken"; |
|
103 | - } |
|
93 | + /** |
|
94 | + * @see Security::getPasswordResetLink() |
|
95 | + * We overload this, so we can add the BackURL to the password resetlink |
|
96 | + */ |
|
97 | + public static function getPasswordResetLink($member, $autologinToken) |
|
98 | + { |
|
99 | + $autologinToken = urldecode($autologinToken); |
|
100 | + $selfControllerClass = __CLASS__; |
|
101 | + $selfController = new $selfControllerClass(); |
|
102 | + return $selfController->Link('changepassword') . "?m={$member->ID}&t=$autologinToken"; |
|
103 | + } |
|
104 | 104 | |
105 | - /** |
|
106 | - * @return ChangePasswordForm |
|
107 | - */ |
|
108 | - public function ChangePasswordForm() |
|
109 | - { |
|
110 | - return new ChangePasswordForm($this, 'ChangePasswordForm'); |
|
111 | - } |
|
105 | + /** |
|
106 | + * @return ChangePasswordForm |
|
107 | + */ |
|
108 | + public function ChangePasswordForm() |
|
109 | + { |
|
110 | + return new ChangePasswordForm($this, 'ChangePasswordForm'); |
|
111 | + } |
|
112 | 112 | } |
@@ -75,7 +75,7 @@ |
||
75 | 75 | public static function getBackUrl() |
76 | 76 | { |
77 | 77 | $request = Controller::curr()->getRequest(); |
78 | - if($url = $request->requestVar('BackURL')) { |
|
78 | + if ($url = $request->requestVar('BackURL')) { |
|
79 | 79 | return $url; |
80 | 80 | } |
81 | 81 | return ''; |
@@ -10,19 +10,19 @@ |
||
10 | 10 | class AdminLoginExtension extends Extension |
11 | 11 | { |
12 | 12 | |
13 | - /** |
|
14 | - * Redirect to AdminSecurity, when we are coming from /admin/* |
|
15 | - * |
|
16 | - * @return SS_HTTPResponse|void |
|
17 | - */ |
|
18 | - public function onBeforeSecurityLogin() |
|
19 | - { |
|
20 | - $backUrl = $this->owner->getRequest()->getVar('BackURL'); |
|
21 | - if (strstr($backUrl, '/admin/')) { |
|
22 | - if (Controller::curr()->class != 'AdminSecurity') { |
|
23 | - $link = 'AdminSecurity/login' . '?BackURL=' . urlencode($backUrl); |
|
24 | - return $this->owner->redirect($link); |
|
25 | - } |
|
26 | - } |
|
27 | - } |
|
13 | + /** |
|
14 | + * Redirect to AdminSecurity, when we are coming from /admin/* |
|
15 | + * |
|
16 | + * @return SS_HTTPResponse|void |
|
17 | + */ |
|
18 | + public function onBeforeSecurityLogin() |
|
19 | + { |
|
20 | + $backUrl = $this->owner->getRequest()->getVar('BackURL'); |
|
21 | + if (strstr($backUrl, '/admin/')) { |
|
22 | + if (Controller::curr()->class != 'AdminSecurity') { |
|
23 | + $link = 'AdminSecurity/login' . '?BackURL=' . urlencode($backUrl); |
|
24 | + return $this->owner->redirect($link); |
|
25 | + } |
|
26 | + } |
|
27 | + } |
|
28 | 28 | } |
@@ -5,25 +5,25 @@ |
||
5 | 5 | */ |
6 | 6 | class LimitAdminAccessExtension extends Extension |
7 | 7 | { |
8 | - /** |
|
9 | - * @return mixed |
|
10 | - */ |
|
11 | - public function onBeforeInit() |
|
12 | - { |
|
13 | - if (Config::inst()->get('IpAccess', 'enabled')) { |
|
14 | - $ipAccess = new IpAccess($this->owner->getRequest()->getIP(), |
|
15 | - Config::inst()->get('IpAccess', 'allowed_ips')); |
|
8 | + /** |
|
9 | + * @return mixed |
|
10 | + */ |
|
11 | + public function onBeforeInit() |
|
12 | + { |
|
13 | + if (Config::inst()->get('IpAccess', 'enabled')) { |
|
14 | + $ipAccess = new IpAccess($this->owner->getRequest()->getIP(), |
|
15 | + Config::inst()->get('IpAccess', 'allowed_ips')); |
|
16 | 16 | |
17 | - if (!$ipAccess->hasAccess()) { |
|
18 | - $response = null; |
|
19 | - if (class_exists('ErrorPage', true)) { |
|
20 | - $response = ErrorPage::response_for(403); |
|
21 | - } |
|
17 | + if (!$ipAccess->hasAccess()) { |
|
18 | + $response = null; |
|
19 | + if (class_exists('ErrorPage', true)) { |
|
20 | + $response = ErrorPage::response_for(403); |
|
21 | + } |
|
22 | 22 | |
23 | - $response = ($response) ? $response : 'The requested page could not be found.'; |
|
23 | + $response = ($response) ? $response : 'The requested page could not be found.'; |
|
24 | 24 | |
25 | - return $this->owner->httpError(403, $response); |
|
26 | - } |
|
27 | - } |
|
28 | - } |
|
25 | + return $this->owner->httpError(403, $response); |
|
26 | + } |
|
27 | + } |
|
28 | + } |
|
29 | 29 | } |