1 | <?php |
||
14 | class DefaultAdminService |
||
15 | { |
||
16 | use Extensible; |
||
17 | use Configurable; |
||
18 | use Injectable; |
||
19 | |||
20 | /** |
||
21 | * @var bool |
||
22 | */ |
||
23 | protected static $has_default_admin = false; |
||
24 | |||
25 | /** |
||
26 | * @var string |
||
27 | */ |
||
28 | protected static $default_username = null; |
||
29 | |||
30 | /** |
||
31 | * @var string |
||
32 | */ |
||
33 | protected static $default_password = null; |
||
34 | |||
35 | public function __construct() |
||
39 | |||
40 | /** |
||
41 | * Set the default admin credentials |
||
42 | * |
||
43 | * @param string $username |
||
44 | * @param string $password |
||
45 | */ |
||
46 | public static function setDefaultAdmin($username, $password) |
||
63 | |||
64 | /** |
||
65 | * @return string The default admin username |
||
66 | * @throws BadMethodCallException Throws exception if there is no default admin |
||
67 | */ |
||
68 | public static function getDefaultAdminUsername() |
||
77 | |||
78 | /** |
||
79 | * @return string The default admin password |
||
80 | * @throws BadMethodCallException Throws exception if there is no default admin |
||
81 | */ |
||
82 | public static function getDefaultAdminPassword() |
||
91 | |||
92 | /** |
||
93 | * Check if there is a default admin |
||
94 | * |
||
95 | * @return bool |
||
96 | */ |
||
97 | public static function hasDefaultAdmin() |
||
101 | |||
102 | /** |
||
103 | * Flush the default admin credentials |
||
104 | */ |
||
105 | public static function clearDefaultAdmin() |
||
111 | |||
112 | /** |
||
113 | * @return Member|null |
||
114 | */ |
||
115 | public function findOrCreateDefaultAdmin() |
||
162 | |||
163 | /** |
||
164 | * Check if the user is a default admin. |
||
165 | * Returns false if there is no default admin. |
||
166 | * |
||
167 | * @param string $username |
||
168 | * @return bool |
||
169 | */ |
||
170 | public static function isDefaultAdmin($username) |
||
176 | |||
177 | /** |
||
178 | * Check if the user credentials match the default admin. |
||
179 | * Returns false if there is no default admin. |
||
180 | * |
||
181 | * @param string $username |
||
182 | * @param string $password |
||
183 | * @return bool |
||
184 | */ |
||
185 | public static function isDefaultAdminCredentials($username, $password) |
||
191 | } |
||
192 |