mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Refactoring SecurityComponent callbacks
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@3121 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
06c626c113
commit
f809a0652d
1 changed files with 17 additions and 5 deletions
|
@ -135,7 +135,7 @@ class SecurityComponent extends Object {
|
|||
if (low($this->loginOptions['type']) == 'digest') {
|
||||
// Do digest authentication
|
||||
} else {
|
||||
if (!(in_array($login[0], array_keys($this->loginUsers)) && $this->loginUsers[$login[0]] == $login[1])) {
|
||||
if (!(in_array($login['username'], array_keys($this->loginUsers)) && $this->loginUsers[$login['username']] == $login['password'])) {
|
||||
$this->blackHole($controller, 'login');
|
||||
}
|
||||
}
|
||||
|
@ -172,8 +172,8 @@ class SecurityComponent extends Object {
|
|||
header('HTTP/1.0 404 Not Found');
|
||||
}
|
||||
exit();
|
||||
} elseif (method_exists($controller, $this->blackHoleCallback)) {
|
||||
return $controller->{$this->blackHoleCallback}($error);
|
||||
} else {
|
||||
return $this->__callback($controller, $this->blackHoleCallback, array($error));
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
@ -225,8 +225,8 @@ class SecurityComponent extends Object {
|
|||
function loginCredentials($type = '') {
|
||||
|
||||
if ($type == '' || low($type) == 'basic') {
|
||||
$login = array(env('PHP_AUTH_USER'), env('PHP_AUTH_PW'));
|
||||
if ($login[0] != null) {
|
||||
$login = array('username' => env('PHP_AUTH_USER'), 'password' => env('PHP_AUTH_PW'));
|
||||
if ($login['username'] != null) {
|
||||
return $login;
|
||||
}
|
||||
}
|
||||
|
@ -317,6 +317,18 @@ class SecurityComponent extends Object {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Private method
|
||||
*
|
||||
*/
|
||||
function __callback(&$controller, $method, $params = array()) {
|
||||
if (is_callable(array($controller, $method))) {
|
||||
return call_user_func_array(array(&$controller, $method), empty($params) ? null : $params);
|
||||
} else {
|
||||
// Debug::warning('Callback method ' . $method . ' in controller ' . get_class($controller)
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Loading…
Reference in a new issue