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:
nate 2008-02-02 04:51:49 +00:00
parent 881cf3fc0a
commit 71bd08b950
3 changed files with 18 additions and 10 deletions

View file

@ -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();
} }
} }

View file

@ -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.

View file

@ -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;
} }