public function setUp()
 {
     // This test assumes that MemberAuthenticator is present and the default
     $this->priorAuthenticators = Authenticator::get_authenticators();
     $this->priorDefaultAuthenticator = Authenticator::get_default_authenticator();
     foreach ($this->priorAuthenticators as $authenticator) {
         Authenticator::unregister($authenticator);
     }
     Authenticator::register('SilverStripe\\Security\\MemberAuthenticator');
     Authenticator::set_default_authenticator('SilverStripe\\Security\\MemberAuthenticator');
     // And that the unique identified field is 'Email'
     $this->priorUniqueIdentifierField = Member::config()->unique_identifier_field;
     $this->priorRememberUsername = Security::config()->remember_username;
     Member::config()->unique_identifier_field = 'Email';
     parent::setUp();
 }
 public function setUp()
 {
     // This test assumes that MemberAuthenticator is present and the default
     $this->priorAuthenticators = Authenticator::get_authenticators();
     $this->priorDefaultAuthenticator = Authenticator::get_default_authenticator();
     foreach ($this->priorAuthenticators as $authenticator) {
         Authenticator::unregister($authenticator);
     }
     Authenticator::register('SilverStripe\\Security\\MemberAuthenticator');
     Authenticator::set_default_authenticator('SilverStripe\\Security\\MemberAuthenticator');
     // And that the unique identified field is 'Email'
     $this->priorUniqueIdentifierField = Member::config()->unique_identifier_field;
     $this->priorRememberUsername = Security::config()->remember_username;
     /** @skipUpgrade */
     Member::config()->unique_identifier_field = 'Email';
     parent::setUp();
     Config::inst()->update('SilverStripe\\Control\\Director', 'alternate_base_url', '/');
 }
Ejemplo n.º 3
0
 /**
  * Get the login forms for all available authentication methods
  *
  * @return array Returns an array of available login forms (array of Form
  *               objects).
  *
  * @todo Check how to activate/deactivate authentication methods
  */
 public function GetLoginForms()
 {
     $forms = array();
     $authenticators = Authenticator::get_authenticators();
     foreach ($authenticators as $authenticator) {
         $forms[] = $authenticator::get_login_form($this);
     }
     return $forms;
 }
 /**
  * Determine if CMSSecurity is enabled
  *
  * @return bool
  */
 public static function enabled()
 {
     // Disable shortcut
     if (!static::config()->reauth_enabled) {
         return false;
     }
     // Count all cms-supported methods
     $authenticators = Authenticator::get_authenticators();
     foreach ($authenticators as $authenticator) {
         // Supported if at least one authenticator is supported
         if ($authenticator::supports_cms()) {
             return true;
         }
     }
     return false;
 }