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') {
|
if (low($this->loginOptions['type']) == 'digest') {
|
||||||
// Do digest authentication
|
// Do digest authentication
|
||||||
} else {
|
} 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');
|
$this->blackHole($controller, 'login');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -172,8 +172,8 @@ class SecurityComponent extends Object {
|
||||||
header('HTTP/1.0 404 Not Found');
|
header('HTTP/1.0 404 Not Found');
|
||||||
}
|
}
|
||||||
exit();
|
exit();
|
||||||
} elseif (method_exists($controller, $this->blackHoleCallback)) {
|
} else {
|
||||||
return $controller->{$this->blackHoleCallback}($error);
|
return $this->__callback($controller, $this->blackHoleCallback, array($error));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -225,8 +225,8 @@ class SecurityComponent extends Object {
|
||||||
function loginCredentials($type = '') {
|
function loginCredentials($type = '') {
|
||||||
|
|
||||||
if ($type == '' || low($type) == 'basic') {
|
if ($type == '' || low($type) == 'basic') {
|
||||||
$login = array(env('PHP_AUTH_USER'), env('PHP_AUTH_PW'));
|
$login = array('username' => env('PHP_AUTH_USER'), 'password' => env('PHP_AUTH_PW'));
|
||||||
if ($login[0] != null) {
|
if ($login['username'] != null) {
|
||||||
return $login;
|
return $login;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -317,6 +317,18 @@ class SecurityComponent extends Object {
|
||||||
return null;
|
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