1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
|
4
|
|
|
/** |
5
|
|
|
* Class AdminSecurity |
6
|
|
|
*/ |
7
|
|
|
class AdminSecurity extends Security |
|
|
|
|
8
|
|
|
{ |
9
|
|
|
/** |
10
|
|
|
* @var array |
11
|
|
|
*/ |
12
|
|
|
private static $allowed_actions = array( |
|
|
|
|
13
|
|
|
'passwordsent', |
14
|
|
|
'ChangePasswordForm' |
15
|
|
|
); |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Template thats used to render the pages. |
19
|
|
|
* |
20
|
|
|
* @config |
21
|
|
|
* @var string |
22
|
|
|
*/ |
23
|
|
|
private static $template_main = 'AdminLogin'; |
|
|
|
|
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @return void |
27
|
|
|
*/ |
28
|
|
|
public function init() |
29
|
|
|
{ |
30
|
|
|
parent::init(); |
31
|
|
|
|
32
|
|
|
$access = new IpAccess($this->getRequest()->getIP()); |
33
|
|
|
if (!$access->hasAccess()) { |
34
|
|
|
$access->respondNoAccess($this); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
if (Config::inst()->get('AdminLogin', 'UseTheme') !== true) { |
38
|
|
|
// this prevents loading frontend css and javscript files |
39
|
|
|
Object::useCustomClass('Page_Controller', 'AdminLoginPage_Controller'); |
40
|
|
|
Requirements::css('adminlogin/css/style.css'); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
Object::useCustomClass('MemberLoginForm', 'AdminLoginForm'); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* @param null $action |
48
|
|
|
* @return string |
49
|
|
|
*/ |
50
|
|
|
public function Link($action = null) |
51
|
|
|
{ |
52
|
|
|
return "AdminSecurity/$action"; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @return string |
57
|
|
|
*/ |
58
|
|
|
public static function isAdminLogin() |
59
|
|
|
{ |
60
|
|
|
return strstr(self::getBackUrl(), '/admin/'); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @return string |
65
|
|
|
*/ |
66
|
|
|
public static function getBackUrl() |
67
|
|
|
{ |
68
|
|
|
$request = Controller::curr()->getRequest(); |
69
|
|
|
if ($url = $request->requestVar('BackURL')) { |
70
|
|
|
return $url; |
71
|
|
|
} |
72
|
|
|
return ''; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @param SS_HTTPRequest $request |
77
|
|
|
* @return SS_HTTPResponse|HTMLText |
78
|
|
|
*/ |
79
|
|
|
public function passwordsent($request) |
80
|
|
|
{ |
81
|
|
|
return parent::passwordsent($request); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @see Security::getPasswordResetLink() |
86
|
|
|
* We overload this, so we can add the BackURL to the password resetlink |
87
|
|
|
* @param Member $member |
88
|
|
|
* @param string $autologinToken |
89
|
|
|
* @return string |
90
|
|
|
*/ |
91
|
|
|
public static function getPasswordResetLink($member, $autologinToken) |
92
|
|
|
{ |
93
|
|
|
$autologinToken = urldecode($autologinToken); |
94
|
|
|
$selfControllerClass = __CLASS__; |
95
|
|
|
$selfController = new $selfControllerClass(); |
96
|
|
|
return $selfController->Link('changepassword') . "?m={$member->ID}&t=$autologinToken"; |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @return ChangePasswordForm |
101
|
|
|
*/ |
102
|
|
|
public function ChangePasswordForm() |
103
|
|
|
{ |
104
|
|
|
return new ChangePasswordForm($this, 'ChangePasswordForm'); |
105
|
|
|
} |
106
|
|
|
} |
107
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.