mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02: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'
|
replacement: 'writeJavascriptToBody'
|
||||||
'SilverStripe\Forms\Formfield->dontEscape':
|
'SilverStripe\Forms\Formfield->dontEscape':
|
||||||
message: 'FormField::$dontEscape has been removed. Escaping is now managed on a class by class basis.'
|
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':
|
'SilverStripe\Security\Permission::$declared_permissions':
|
||||||
message: 'Deprecated'
|
message: 'Deprecated'
|
||||||
'SilverStripe\Security\Permission::$declared_permissions_list':
|
'SilverStripe\Security\Permission::$declared_permissions_list':
|
||||||
|
@ -15,26 +15,56 @@ use SilverStripe\Forms\Form;
|
|||||||
*/
|
*/
|
||||||
abstract class LoginForm extends Form
|
abstract class LoginForm extends Form
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Authenticator class to use with this login form
|
* @deprecated 4.4.0:5.0.0 Use getAuthenticatorClass() or setAuthenticatorClass() instead
|
||||||
*
|
|
||||||
* Set this variable to the authenticator class to use with this login
|
|
||||||
* form.
|
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $authenticator_class;
|
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)
|
public function setAuthenticatorClass($class)
|
||||||
{
|
{
|
||||||
$this->authenticator_class = $class;
|
$this->authenticatorClass = $class;
|
||||||
$authenticatorField = $this->Fields()->dataFieldByName('AuthenticationMethod');
|
|
||||||
|
/** @var FieldList|null $fields */
|
||||||
|
$fields = $this->Fields();
|
||||||
|
if (!$fields) {
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
$authenticatorField = $fields->dataFieldByName('AuthenticationMethod');
|
||||||
if ($authenticatorField) {
|
if ($authenticatorField) {
|
||||||
$authenticatorField->setValue($class);
|
$authenticatorField->setValue($class);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
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
|
* Return the title of the form for use in the frontend
|
||||||
* For tabs with multiple login methods, for example.
|
* For tabs with multiple login methods, for example.
|
||||||
|
@ -30,7 +30,7 @@ class CMSMemberLoginForm extends MemberLoginForm
|
|||||||
{
|
{
|
||||||
$this->controller = $controller;
|
$this->controller = $controller;
|
||||||
|
|
||||||
$this->authenticator_class = $authenticatorClass;
|
$this->setAuthenticatorClass($authenticatorClass);
|
||||||
|
|
||||||
$fields = $this->getFormFields();
|
$fields = $this->getFormFields();
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ class CMSMemberLoginForm extends MemberLoginForm
|
|||||||
{
|
{
|
||||||
// Set default fields
|
// Set default fields
|
||||||
$fields = FieldList::create([
|
$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')),
|
HiddenField::create('tempid', null, $this->controller->getRequest()->requestVar('tempid')),
|
||||||
PasswordField::create("Password", _t('SilverStripe\\Security\\Member.PASSWORD', 'Password'))
|
PasswordField::create("Password", _t('SilverStripe\\Security\\Member.PASSWORD', 'Password'))
|
||||||
]);
|
]);
|
||||||
|
@ -77,7 +77,7 @@ class MemberLoginForm extends BaseLoginForm
|
|||||||
$checkCurrentUser = true
|
$checkCurrentUser = true
|
||||||
) {
|
) {
|
||||||
$this->setController($controller);
|
$this->setController($controller);
|
||||||
$this->authenticator_class = $authenticatorClass;
|
$this->setAuthenticatorClass($authenticatorClass);
|
||||||
|
|
||||||
$customCSS = project() . '/css/member_login.css';
|
$customCSS = project() . '/css/member_login.css';
|
||||||
if (Director::fileExists($customCSS)) {
|
if (Director::fileExists($customCSS)) {
|
||||||
@ -88,7 +88,7 @@ class MemberLoginForm extends BaseLoginForm
|
|||||||
// @todo find a more elegant way to handle this
|
// @todo find a more elegant way to handle this
|
||||||
$logoutAction = Security::logout_url();
|
$logoutAction = Security::logout_url();
|
||||||
$fields = FieldList::create(
|
$fields = FieldList::create(
|
||||||
HiddenField::create('AuthenticationMethod', null, $this->authenticator_class, $this)
|
HiddenField::create('AuthenticationMethod', null, $this->getAuthenticatorClass(), $this)
|
||||||
);
|
);
|
||||||
$actions = FieldList::create(
|
$actions = FieldList::create(
|
||||||
FormAction::create('logout', _t(
|
FormAction::create('logout', _t(
|
||||||
@ -133,7 +133,7 @@ class MemberLoginForm extends BaseLoginForm
|
|||||||
|
|
||||||
$label = Member::singleton()->fieldLabel(Member::config()->get('unique_identifier_field'));
|
$label = Member::singleton()->fieldLabel(Member::config()->get('unique_identifier_field'));
|
||||||
$fields = FieldList::create(
|
$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
|
// Regardless of what the unique identifer field is (usually 'Email'), it will be held in the
|
||||||
// 'Email' value, below:
|
// 'Email' value, below:
|
||||||
// @todo Rename the field to a more generic covering name
|
// @todo Rename the field to a more generic covering name
|
||||||
|
Loading…
Reference in New Issue
Block a user