2007-09-16 02:44:30 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* 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>
|
2012-04-12 08:02:46 +02:00
|
|
|
* @package framework
|
2008-02-25 03:10:37 +01:00
|
|
|
* @subpackage security
|
2007-09-16 02:44:30 +02:00
|
|
|
*/
|
|
|
|
abstract class LoginForm extends Form {
|
2007-10-28 22:44:38 +01:00
|
|
|
function __construct($controller, $name, $fields, $actions) {
|
|
|
|
parent::__construct($controller, $name, $fields, $actions);
|
|
|
|
|
|
|
|
$this->disableSecurityToken();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Authenticator class to use with this login form
|
|
|
|
*
|
|
|
|
* Set this variable to the authenticator class to use with this login
|
|
|
|
* form.
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
|
|
|
|
protected $authenticator_class;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the authenticator class
|
|
|
|
* @return Authenticator Returns the authenticator class for this login form.
|
|
|
|
*/
|
|
|
|
|
|
|
|
public function getAuthenticator() {
|
|
|
|
if(!class_exists($this->authenticator_class) || !is_subclass_of($this->authenticator_class, 'Authenticator')) {
|
2008-10-08 04:00:12 +02:00
|
|
|
user_error("The form uses an invalid authenticator class! '{$this->authenticator_class}' is not a subclass of 'Authenticator'", E_USER_ERROR);
|
2007-10-28 22:44:38 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
return new $this->authenticator_class;
|
|
|
|
}
|
2007-09-16 02:44:30 +02:00
|
|
|
}
|
|
|
|
|