mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Merge pull request #5681 from dhensby/pulls/3/injector-login-form
NEW Use injector for MemberLoginForm fields
This commit is contained in:
commit
65afd6c354
@ -67,21 +67,21 @@ class MemberLoginForm extends LoginForm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if($checkCurrentUser && Member::currentUser() && Member::logged_in_session_exists()) {
|
if($checkCurrentUser && Member::currentUser() && Member::logged_in_session_exists()) {
|
||||||
$fields = new FieldList(
|
$fields = FieldList::create(
|
||||||
new HiddenField("AuthenticationMethod", null, $this->authenticator_class, $this)
|
HiddenField::create("AuthenticationMethod", null, $this->authenticator_class, $this)
|
||||||
);
|
);
|
||||||
$actions = new FieldList(
|
$actions = FieldList::create(
|
||||||
new FormAction("logout", _t('Member.BUTTONLOGINOTHER', "Log in as someone else"))
|
FormAction::create("logout", _t('Member.BUTTONLOGINOTHER', "Log in as someone else"))
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
if(!$fields) {
|
if(!$fields) {
|
||||||
$label=singleton('Member')->fieldLabel(Member::config()->unique_identifier_field);
|
$label=singleton('Member')->fieldLabel(Member::config()->unique_identifier_field);
|
||||||
$fields = new FieldList(
|
$fields = FieldList::create(
|
||||||
new HiddenField("AuthenticationMethod", null, $this->authenticator_class, $this),
|
HiddenField::create("AuthenticationMethod", null, $this->authenticator_class, $this),
|
||||||
// Regardless of what the unique identifer field is (usually 'Email'), it will be held in the
|
// Regardless of what the unique identifer field is (usually 'Email'), it will be held in the
|
||||||
// 'Email' value, below:
|
// 'Email' value, below:
|
||||||
$emailField = new TextField("Email", $label, null, null, $this),
|
$emailField = TextField::create("Email", $label, null, null, $this),
|
||||||
new PasswordField("Password", _t('Member.PASSWORD', 'Password'))
|
PasswordField::create("Password", _t('Member.PASSWORD', 'Password'))
|
||||||
);
|
);
|
||||||
if(Security::config()->remember_username) {
|
if(Security::config()->remember_username) {
|
||||||
$emailField->setValue(Session::get('SessionForms.MemberLoginForm.Email'));
|
$emailField->setValue(Session::get('SessionForms.MemberLoginForm.Email'));
|
||||||
@ -91,16 +91,16 @@ class MemberLoginForm extends LoginForm {
|
|||||||
$emailField->setAttribute('autocomplete', 'off');
|
$emailField->setAttribute('autocomplete', 'off');
|
||||||
}
|
}
|
||||||
if(Security::config()->autologin_enabled) {
|
if(Security::config()->autologin_enabled) {
|
||||||
$fields->push(new CheckboxField(
|
$fields->push(CheckboxField::create(
|
||||||
"Remember",
|
"Remember",
|
||||||
_t('Member.REMEMBERME', "Remember me next time?")
|
_t('Member.REMEMBERME', "Remember me next time?")
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!$actions) {
|
if(!$actions) {
|
||||||
$actions = new FieldList(
|
$actions = FieldList::create(
|
||||||
new FormAction('dologin', _t('Member.BUTTONLOGIN', "Log in")),
|
FormAction::create('dologin', _t('Member.BUTTONLOGIN', "Log in")),
|
||||||
new LiteralField(
|
LiteralField::create(
|
||||||
'forgotPassword',
|
'forgotPassword',
|
||||||
'<p id="ForgotPassword"><a href="Security/lostpassword">'
|
'<p id="ForgotPassword"><a href="Security/lostpassword">'
|
||||||
. _t('Member.BUTTONLOSTPASSWORD', "I've lost my password") . '</a></p>'
|
. _t('Member.BUTTONLOSTPASSWORD', "I've lost my password") . '</a></p>'
|
||||||
@ -110,7 +110,7 @@ class MemberLoginForm extends LoginForm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(isset($backURL)) {
|
if(isset($backURL)) {
|
||||||
$fields->push(new HiddenField('BackURL', 'BackURL', $backURL));
|
$fields->push(HiddenField::create('BackURL', 'BackURL', $backURL));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reduce attack surface by enforcing POST requests
|
// Reduce attack surface by enforcing POST requests
|
||||||
@ -118,7 +118,7 @@ class MemberLoginForm extends LoginForm {
|
|||||||
|
|
||||||
parent::__construct($controller, $name, $fields, $actions);
|
parent::__construct($controller, $name, $fields, $actions);
|
||||||
|
|
||||||
$this->setValidator(new RequiredFields('Email', 'Password'));
|
$this->setValidator(RequiredFields::create('Email', 'Password'));
|
||||||
|
|
||||||
// Focus on the email input when the page is loaded
|
// Focus on the email input when the page is loaded
|
||||||
$js = <<<JS
|
$js = <<<JS
|
||||||
@ -204,7 +204,7 @@ JS;
|
|||||||
if(isset($_REQUEST['BackURL']) && $backURL = $_REQUEST['BackURL']) {
|
if(isset($_REQUEST['BackURL']) && $backURL = $_REQUEST['BackURL']) {
|
||||||
Session::set('BackURL', $backURL);
|
Session::set('BackURL', $backURL);
|
||||||
}
|
}
|
||||||
$cp = new ChangePasswordForm($this->controller, 'ChangePasswordForm');
|
$cp = ChangePasswordForm::create($this->controller, 'ChangePasswordForm');
|
||||||
$cp->sessionMessage(
|
$cp->sessionMessage(
|
||||||
_t('Member.PASSWORDEXPIRED', 'Your password has expired. Please choose a new one.'),
|
_t('Member.PASSWORDEXPIRED', 'Your password has expired. Please choose a new one.'),
|
||||||
'good'
|
'good'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user