2007-09-16 02:44:30 +02:00
|
|
|
<?php
|
2016-06-23 01:37:22 +02:00
|
|
|
|
|
|
|
namespace SilverStripe\Security;
|
|
|
|
|
2017-04-17 05:07:28 +02:00
|
|
|
use SilverStripe\Forms\FieldList;
|
2016-08-19 00:51:35 +02:00
|
|
|
use SilverStripe\Forms\Form;
|
2016-06-23 01:37:22 +02:00
|
|
|
|
2007-09-16 02:44:30 +02:00
|
|
|
/**
|
|
|
|
* Abstract base class for a login form
|
|
|
|
*
|
|
|
|
* This class is used as a base class for the different log-in forms like
|
|
|
|
* {@link MemberLoginForm} or {@link OpenIDLoginForm}.
|
|
|
|
*
|
|
|
|
* @author Markus Lanthaler <markus@silverstripe.com>
|
|
|
|
*/
|
2016-11-29 00:31:16 +01:00
|
|
|
abstract class LoginForm extends Form
|
|
|
|
{
|
2018-11-05 13:47:47 +01:00
|
|
|
/**
|
|
|
|
* @deprecated 4.4.0:5.0.0 Use getAuthenticatorClass() or setAuthenticatorClass() instead
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $authenticator_class;
|
2016-11-29 00:31:16 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Authenticator class to use with this login form
|
|
|
|
*
|
2018-11-05 13:47:47 +01:00
|
|
|
* Set this variable to the authenticator class to use with this login form.
|
|
|
|
*
|
2016-11-29 00:31:16 +01:00
|
|
|
* @var string
|
|
|
|
*/
|
2018-11-05 13:47:47 +01:00
|
|
|
protected $authenticatorClass;
|
2016-11-29 00:31:16 +01:00
|
|
|
|
2018-11-05 13:47:47 +01:00
|
|
|
/**
|
|
|
|
* Set the authenticator class name to use
|
|
|
|
*
|
|
|
|
* @param string $class
|
|
|
|
* @return $this
|
|
|
|
*/
|
2017-10-05 17:40:31 +02:00
|
|
|
public function setAuthenticatorClass($class)
|
|
|
|
{
|
2018-11-05 13:47:47 +01:00
|
|
|
$this->authenticatorClass = $class;
|
2017-10-05 17:40:31 +02:00
|
|
|
$authenticatorField = $this->Fields()->dataFieldByName('AuthenticationMethod');
|
|
|
|
if ($authenticatorField) {
|
|
|
|
$authenticatorField->setValue($class);
|
|
|
|
}
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2018-11-05 13:47:47 +01:00
|
|
|
/**
|
|
|
|
* 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;
|
|
|
|
}
|
|
|
|
|
2016-11-29 00:31:16 +01:00
|
|
|
/**
|
2017-04-14 05:30:55 +02:00
|
|
|
* Return the title of the form for use in the frontend
|
|
|
|
* For tabs with multiple login methods, for example.
|
|
|
|
* This replaces the old `get_name` method
|
|
|
|
* @return string
|
2016-11-29 00:31:16 +01:00
|
|
|
*/
|
2017-04-14 05:30:55 +02:00
|
|
|
abstract public function getAuthenticatorName();
|
2017-04-17 05:07:28 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Required FieldList creation on a LoginForm
|
|
|
|
*
|
|
|
|
* @return FieldList
|
|
|
|
*/
|
|
|
|
abstract protected function getFormFields();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Required FieldList creation for the login actions on this LoginForm
|
|
|
|
*
|
|
|
|
* @return FieldList
|
|
|
|
*/
|
|
|
|
abstract protected function getFormActions();
|
2007-09-16 02:44:30 +02:00
|
|
|
}
|