Added support for password and old_password encryption mechanisms if you're using MySQL

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.2.2@50283 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2008-02-27 04:36:18 +00:00
parent b1480d5a56
commit b09856545d

View File

@ -648,6 +648,15 @@ class Security extends Controller {
}
}
// Support for MySQL password() and old_password() functions. These aren't recommended unless you need them,
// but can be helpful for migrating legacy user-sets into a SilverStripe application.
// Since DB::getConn() doesn't exist yet, we need to look at $databaseConfig. Gack!
global $databaseConfig;
if($databaseConfig['type'] == 'MySQLDatabase') {
$result[] = 'password';
$result[] = 'old_password';
}
return $result;
}
@ -749,6 +758,17 @@ class Security extends Controller {
$algorithm = self::$encryptionAlgorithm;
}
// Support for MySQL password() and old_password() authentication
if(strtolower($algorithm) == 'password' || strtolower($algorithm) == 'old_password') {
$SQL_password = Convert::raw2sql($password);
$enc = DB::query("SELECT $algorithm('$SQL_password')")->value();
return array(
'password' => $enc,
'salt' => null,
'algorithm' => $algorithm,
);
}
// If no salt was provided but we need one we just generate a random one
if(strlen(trim($salt)) == 0)