API CHANGE: Unique_identifier now accepted as the login requirement, allowing alternatives to 'Email'

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@97270 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Geoff Munn 2010-01-20 20:17:25 +00:00 committed by Sam Minnee
parent 1c851476b6
commit f4de365be8
3 changed files with 7 additions and 5 deletions

View File

@ -39,7 +39,7 @@ class MemberAuthenticator extends Authenticator {
} else {
$member = DataObject::get_one(
"Member",
"\"Email\" = '$SQL_user' AND \"Password\" IS NOT NULL"
"\"" . Member::get_unique_identifier_field() . "\" = '$SQL_user' AND \"Password\" IS NOT NULL"
);
if($member && ($member->checkPassword($RAW_data['Password']) == false)) {
@ -64,7 +64,7 @@ class MemberAuthenticator extends Authenticator {
$member->extend('authenticated');
} else {
// failed login - we're trying to see if a user exists with this email (disregarding wrong passwords)
$existingMember = DataObject::get_one("Member", "\"Email\" = '$SQL_user'");
$existingMember = DataObject::get_one("Member", "\"" . Member::get_unique_identifier_field() . "\" = '$SQL_user'");
if($existingMember) {
$attempt->MemberID = $existingMember->ID;

View File

@ -52,9 +52,11 @@ class MemberLoginForm extends LoginForm {
);
} else {
if(!$fields) {
$label=singleton('Member')->fieldLabel(Member::get_unique_identifier_field());
$fields = new FieldSet(
new HiddenField("AuthenticationMethod", null, $this->authenticator_class, $this),
new TextField("Email", _t('Member.EMAIL', 'Email'), Session::get('SessionForms.MemberLoginForm.Email'), null, $this),
//Regardless of what the unique identifer field is (usually 'Email'), it will be held in the 'Email' value, below:
new TextField("Email", $label, Session::get('SessionForms.MemberLoginForm.Email'), null, $this),
new PasswordField("Password", _t('Member.PASSWORD', 'Password'))
);
if(Security::$autologin_enabled) {

View File

@ -592,7 +592,7 @@ class Security extends Controller {
&& !empty(self::$default_username) && !empty(self::$default_password)) {
$member = self::findAnAdministrator();
} else {
$member = DataObject::get_one("Member", "\"Email\" = '$SQL_email' AND \"Password\" IS NOT NULL");
$member = DataObject::get_one("Member", "\"" . Member::get_unique_identifier_field() . "\" = '$SQL_email' AND \"Password\" IS NOT NULL");
if($member && ($member->checkPassword($RAW_password) == false)) {
$member = null;
}
@ -810,7 +810,7 @@ class Security extends Controller {
$salt = ($salt) ? $salt : $e->salt($password);
return array(
'password' => $e->encrypt($password, $salt),
'password' => $e->encrypt($password, $salt, $member),
'salt' => $salt,
'algorithm' => $algorithm,
'encryptor' => $e