Version: current

     1 <?php
     2 /**
     3  * Abstract base class for a login form
     4  *
     5  * This class is used as a base class for the different log-in forms like
     6  * {@link MemberLoginForm} or {@link OpenIDLoginForm}.
     7  *
     8  * @author Markus Lanthaler <markus@silverstripe.com>
     9  * @package sapphire
    10  * @subpackage security
    11  */
    12 abstract class LoginForm extends Form {
    13     function __construct($controller, $name, $fields, $actions) {
    14         parent::__construct($controller, $name, $fields, $actions);
    15
    16         $this->disableSecurityToken();
    17     }
    18
    19     /**
    20      * Authenticator class to use with this login form
    21      *
    22      * Set this variable to the authenticator class to use with this login
    23      * form.
    24      * @var string
    25      */
    26
    27     protected $authenticator_class;
    28
    29     /**
    30      * Get the authenticator class
    31      * @return Authenticator Returns the authenticator class for this login form.
    32      */
    33
    34     public function getAuthenticator() {
    35         if(!class_exists($this->authenticator_class) || !is_subclass_of($this->authenticator_class, 'Authenticator')) {
    36             user_error("The form uses an invalid authenticator class! '{$this->authenticator_class}' is not a subclass of 'Authenticator'", E_USER_ERROR);
    37             return;
    38         }
    39
    40         return new $this->authenticator_class;
    41     }
    42 }
    43
    44 ?>

[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -