mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Merge pull request #8571 from creative-commoners/pulls/4.4/get-authenticator-class
API LoginForm::authentiator_class is now deprecated, use getters or setters instead
This commit is contained in:
commit
d4e322b6da
@ -1325,6 +1325,8 @@ warnings:
|
||||
replacement: 'writeJavascriptToBody'
|
||||
'SilverStripe\Forms\Formfield->dontEscape':
|
||||
message: 'FormField::$dontEscape has been removed. Escaping is now managed on a class by class basis.'
|
||||
'SilverStripe\Security\LoginForm->authenticator_class':
|
||||
message: 'authenticator_class is deprecated. Use getAuthenticatorClass/setAuthenticatorClass.'
|
||||
'SilverStripe\Security\Permission::$declared_permissions':
|
||||
message: 'Deprecated'
|
||||
'SilverStripe\Security\Permission::$declared_permissions_list':
|
||||
@ -1387,4 +1389,4 @@ warnings:
|
||||
url: 'https://docs.silverstripe.org/en/4/changelogs/4.4.0#resources-dir'
|
||||
replacement: 'RESOURCES_DIR'
|
||||
renameWarnings:
|
||||
- Form
|
||||
- Form
|
||||
|
@ -15,26 +15,56 @@ use SilverStripe\Forms\Form;
|
||||
*/
|
||||
abstract class LoginForm extends Form
|
||||
{
|
||||
|
||||
/**
|
||||
* Authenticator class to use with this login form
|
||||
*
|
||||
* Set this variable to the authenticator class to use with this login
|
||||
* form.
|
||||
* @deprecated 4.4.0:5.0.0 Use getAuthenticatorClass() or setAuthenticatorClass() instead
|
||||
* @var string
|
||||
*/
|
||||
protected $authenticator_class;
|
||||
|
||||
/**
|
||||
* Authenticator class to use with this login form
|
||||
*
|
||||
* Set this variable to the authenticator class to use with this login form.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $authenticatorClass;
|
||||
|
||||
/**
|
||||
* Set the authenticator class name to use
|
||||
*
|
||||
* @param string $class
|
||||
* @return $this
|
||||
*/
|
||||
public function setAuthenticatorClass($class)
|
||||
{
|
||||
$this->authenticator_class = $class;
|
||||
$authenticatorField = $this->Fields()->dataFieldByName('AuthenticationMethod');
|
||||
$this->authenticatorClass = $class;
|
||||
|
||||
/** @var FieldList|null $fields */
|
||||
$fields = $this->Fields();
|
||||
if (!$fields) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$authenticatorField = $fields->dataFieldByName('AuthenticationMethod');
|
||||
if ($authenticatorField) {
|
||||
$authenticatorField->setValue($class);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the authenticator class name to use
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAuthenticatorClass()
|
||||
{
|
||||
// B/C for deprecated authenticator_class property
|
||||
return $this->authenticator_class ?: $this->authenticatorClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the title of the form for use in the frontend
|
||||
* For tabs with multiple login methods, for example.
|
||||
|
@ -30,7 +30,7 @@ class CMSMemberLoginForm extends MemberLoginForm
|
||||
{
|
||||
$this->controller = $controller;
|
||||
|
||||
$this->authenticator_class = $authenticatorClass;
|
||||
$this->setAuthenticatorClass($authenticatorClass);
|
||||
|
||||
$fields = $this->getFormFields();
|
||||
|
||||
@ -48,7 +48,7 @@ class CMSMemberLoginForm extends MemberLoginForm
|
||||
{
|
||||
// Set default fields
|
||||
$fields = FieldList::create([
|
||||
HiddenField::create("AuthenticationMethod", null, $this->authenticator_class, $this),
|
||||
HiddenField::create("AuthenticationMethod", null, $this->getAuthenticatorClass(), $this),
|
||||
HiddenField::create('tempid', null, $this->controller->getRequest()->requestVar('tempid')),
|
||||
PasswordField::create("Password", _t('SilverStripe\\Security\\Member.PASSWORD', 'Password'))
|
||||
]);
|
||||
|
@ -77,7 +77,7 @@ class MemberLoginForm extends BaseLoginForm
|
||||
$checkCurrentUser = true
|
||||
) {
|
||||
$this->setController($controller);
|
||||
$this->authenticator_class = $authenticatorClass;
|
||||
$this->setAuthenticatorClass($authenticatorClass);
|
||||
|
||||
$customCSS = project() . '/css/member_login.css';
|
||||
if (Director::fileExists($customCSS)) {
|
||||
@ -88,7 +88,7 @@ class MemberLoginForm extends BaseLoginForm
|
||||
// @todo find a more elegant way to handle this
|
||||
$logoutAction = Security::logout_url();
|
||||
$fields = FieldList::create(
|
||||
HiddenField::create('AuthenticationMethod', null, $this->authenticator_class, $this)
|
||||
HiddenField::create('AuthenticationMethod', null, $this->getAuthenticatorClass(), $this)
|
||||
);
|
||||
$actions = FieldList::create(
|
||||
FormAction::create('logout', _t(
|
||||
@ -133,7 +133,7 @@ class MemberLoginForm extends BaseLoginForm
|
||||
|
||||
$label = Member::singleton()->fieldLabel(Member::config()->get('unique_identifier_field'));
|
||||
$fields = FieldList::create(
|
||||
HiddenField::create("AuthenticationMethod", null, $this->authenticator_class, $this),
|
||||
HiddenField::create("AuthenticationMethod", null, $this->getAuthenticatorClass(), $this),
|
||||
// Regardless of what the unique identifer field is (usually 'Email'), it will be held in the
|
||||
// 'Email' value, below:
|
||||
// @todo Rename the field to a more generic covering name
|
||||
|
Loading…
x
Reference in New Issue
Block a user