mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
API CHANGE: Unique_identifier now accepted as the login requirement, allowing alternatives to 'Email' (from r97270)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@102440 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
6eb4d67c86
commit
b69b03b9e0
@ -40,7 +40,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"
|
||||
);
|
||||
$result = ($member) ? $member->checkPassword($RAW_data['Password']) : false;
|
||||
|
||||
@ -65,7 +65,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;
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -598,7 +598,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;
|
||||
}
|
||||
@ -816,7 +816,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
|
||||
|
Loading…
Reference in New Issue
Block a user