ここの情報は古いです。ご理解頂いた上でお取り扱いください。

Changeset 8725


Ignore:
Timestamp:
Oct 20, 2008, 10:11:06 PM (12 years ago)
Author:
ebihara
Message:

#2888:changes sfOpenPNEAuthForm and sfOpenPNESecurityUser to enable multiple authentication

Location:
OpenPNE3/trunk/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE3/trunk/lib/form/sfOpenPNEAuthForm.class.php

    r8569 r8725  
    1010abstract class sfOpenPNEAuthForm extends sfForm
    1111{
    12   public $memberForm;
    13   public $profileForm;
    14   public $configForm;
     12  public
     13    $memberForm,
     14    $profileForm,
     15    $configForm;
     16
     17  const AUTH_MODE_FIELD_NAME = 'authMode';
    1518
    1619 /**
     
    2023  {
    2124    $this->widgetSchema->setNameFormat('auth[%s]');
     25    $this->addAuthModeField();
    2226  }
     27
     28 /**
     29  * Returns the current auth mode.
     30  *
     31  * The child class must be defined implementation to return the current auth mode.
     32  */
     33  abstract public function getAuthMode();
    2334
    2435 /**
     
    4657
    4758    return $result;
     59  }
     60
     61 /**
     62  * Adds a field to identify the current auth mode.
     63  */
     64  public function addAuthModeField()
     65  {
     66    $this->validatorSchema[self::AUTH_MODE_FIELD_NAME] = new sfValidatorString();
     67    $this->widgetSchema[self::AUTH_MODE_FIELD_NAME] = new sfWidgetFormInputHidden();
     68    $this->setDefault(self::AUTH_MODE_FIELD_NAME, $this->getAuthMode());
    4869  }
    4970
  • OpenPNE3/trunk/lib/user/sfOpenPNESecurityUser.class.php

    r8715 r8725  
    2222    parent::initialize($dispatcher, $storage, $options);
    2323
    24     $authModes = OpenPNEConfig::get(sfConfig::get('sf_app') . '_auth_mode');
    25 
    26     $authMode = $_REQUEST['authMode'];
    27     if (!in_array($authMode, $authModes)) {
     24    $authModes = $this->getAuthModes();
     25
     26    $authMode = '';
     27
     28    if (isset($_REQUEST['authMode']))
     29    {
     30      $authMode = $_REQUEST['authMode'];
     31    }
     32
     33    if (!$authMode || !in_array($authMode, $authModes))
     34    {
    2835      $authMode = array_shift($authModes);
    2936    }
    3037
    31     $containerClass = 'sfOpenPNEAuthContainer_' . $authMode;
     38    $containerClass = self::getAuthContainerClassName($authMode);
    3239    $this->authContainer = new $containerClass();
    3340
    34     $formClass = 'sfOpenPNEAuthForm_' . $authMode;
     41    $formClass = self::getAuthFormClassName($authMode);
    3542    $this->authForm = new $formClass();
    3643
     
    3845  }
    3946
     47  public function getAuthModes()
     48  {
     49    return OpenPNEConfig::get(sfConfig::get('sf_app') . '_auth_mode');
     50  }
     51
    4052  public function getAuthContainer()
    4153  {
     
    4658  {
    4759    return $this->authForm;
     60  }
     61
     62  public function getAuthForms()
     63  {
     64    $result = array();
     65
     66    $authModes = $this->getAuthModes();
     67    foreach ($authModes as $authMode) {
     68      $formClass = self::getAuthFormClassName($authMode);
     69      $result[] = new $formClass();
     70    }
     71
     72    return $result;
     73  }
     74
     75  public static function getAuthFormClassName($authMode)
     76  {
     77    return 'sfOpenPNEAuthForm_'.$authMode;
     78  }
     79
     80  public static function getAuthContainerClassName($authMode)
     81  {
     82    return 'sfOpenPNEAuthContainer_'.$authMode;
    4883  }
    4984
Note: See TracChangeset for help on using the changeset viewer.