mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Refactoring Auth / Security::hash()
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6426 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
881cf3fc0a
commit
71bd08b950
3 changed files with 18 additions and 10 deletions
|
@ -97,20 +97,22 @@ class Component extends Object {
|
||||||
if (is_null($plugin) || !App::import('Component', $plugin . '.' . $component)) {
|
if (is_null($plugin) || !App::import('Component', $plugin . '.' . $component)) {
|
||||||
if (!App::import('Component', $component)) {
|
if (!App::import('Component', $component)) {
|
||||||
$this->cakeError('missingComponentFile', array(array(
|
$this->cakeError('missingComponentFile', array(array(
|
||||||
'className' => $this->controller->name,
|
'className' => $this->controller->name,
|
||||||
'component' => $component,
|
'component' => $component,
|
||||||
'file' => Inflector::underscore($component) . '.php',
|
'file' => Inflector::underscore($component) . '.php',
|
||||||
'base' => $this->controller->base)));
|
'base' => $this->controller->base
|
||||||
|
)));
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!class_exists($componentCn)) {
|
if (!class_exists($componentCn)) {
|
||||||
$this->cakeError('missingComponentClass', array(array(
|
$this->cakeError('missingComponentClass', array(array(
|
||||||
'className' => $this->controller->name,
|
'className' => $this->controller->name,
|
||||||
'component' => $component,
|
'component' => $component,
|
||||||
'file' => Inflector::underscore($component) . '.php',
|
'file' => Inflector::underscore($component) . '.php',
|
||||||
'base' => $this->controller->base)));
|
'base' => $this->controller->base
|
||||||
|
)));
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -791,7 +791,7 @@ class AuthComponent extends Object {
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function password($password) {
|
function password($password) {
|
||||||
return Security::hash(Configure::read('Security.salt') . $password);
|
return Security::hash($password, null, true);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Component shutdown. If user is logged in, wipe out redirect.
|
* Component shutdown. If user is logged in, wipe out redirect.
|
||||||
|
|
|
@ -110,12 +110,18 @@ class Security extends Object {
|
||||||
*
|
*
|
||||||
* @param string $string String to hash
|
* @param string $string String to hash
|
||||||
* @param string $type Method to use (sha1/sha256/md5)
|
* @param string $type Method to use (sha1/sha256/md5)
|
||||||
|
* @param boolean $salt If true, automatically appends the application's salt
|
||||||
|
* value to $string (Security.salt)
|
||||||
* @return string Hash
|
* @return string Hash
|
||||||
* @access public
|
* @access public
|
||||||
* @static
|
* @static
|
||||||
*/
|
*/
|
||||||
function hash($string, $type = null) {
|
function hash($string, $type = null, $salt = false) {
|
||||||
$_this =& Security::getInstance();
|
$_this =& Security::getInstance();
|
||||||
|
|
||||||
|
if ($salt) {
|
||||||
|
$string = Configure::read('Security.salt') . $string;
|
||||||
|
}
|
||||||
if (empty($type)) {
|
if (empty($type)) {
|
||||||
$type = $_this->hashType;
|
$type = $_this->hashType;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue