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

Changeset 8757


Ignore:
Timestamp:
Oct 23, 2008, 11:01:07 AM (11 years ago)
Author:
ebihara
Message:

#2888:Added support for authentication by mobile uid.

Location:
OpenPNE3/trunk
Files:
2 added
10 edited

Legend:

Unmodified
Added
Removed
  • OpenPNE3/trunk/apps/mobile_frontend/modules/member/actions/actions.class.php

    r8705 r8757  
    2020    $this->getUser()->logout();
    2121
    22     $this->form = $this->getUser()->getAuthForm();
     22    $this->forms = $this->getUser()->getAuthForms();
    2323
    24     if ($request->isMethod('post')) {
    25       $this->form->bind($request->getParameter('auth'));
    26       if ($this->form->isValid()) {
    27         $this->redirectIf($this->getUser()->login($this->form), 'member/home');
     24    if ($request->isMethod('post'))
     25    {
     26      $authForm = $this->getUser()->getAuthForm();
     27      $authForm->bind($request->getParameter('auth'.$authForm->getAuthMode()));
     28      if ($authForm->isValid())
     29      {
     30        $this->redirectIf($this->getUser()->login($authForm), 'member/home');
    2831      }
    2932      return sfView::ERROR;
     
    7477    return sfView::SUCCESS;
    7578  }
     79
     80 /**
     81  * Executes configUID action
     82  *
     83  * @param sfRequest $request A request object
     84  */
     85  public function executeConfigUID($request)
     86  {
     87    $option = array('member' => $this->getUser()->getMember());
     88    $this->passwordForm = new sfOpenPNEPasswordForm(array(), $option);
     89
     90    if ($request->isMethod('post')) {
     91      $this->passwordForm->bind($request->getParameter('password'));
     92      if ($this->passwordForm->isValid()) {
     93        $memberConfig = MemberConfigPeer::retrieveByNameAndMemberId('mobile_uid', $this->getUser()->getMemberId());
     94        if (!$memberConfig) {
     95          $memberConfig = new MemberConfig();
     96          $memberConfig->setMember($this->getUser()->getMember());
     97          $memberConfig->setName('mobile_uid');
     98        }
     99        $memberConfig->setValue($request->getMobileUID());
     100        $this->redirectIf($memberConfig->save(), 'member/configUID');
     101      }
     102    }
     103
     104    return sfView::SUCCESS;
     105  }
    76106}
  • OpenPNE3/trunk/apps/mobile_frontend/modules/member/templates/homeSuccess.php

    r8597 r8757  
    11homeSuccess
     2<ul>
     3<li><?php echo link_to('config', 'member/configUID') ?></li>
     4</ul>
  • OpenPNE3/trunk/apps/mobile_frontend/modules/member/templates/loginSuccess.php

    r8598 r8757  
    1 <?php
    2 include_login_parts('login', $form, url_for('member/login'));
    3 ?>
     1<?php foreach ($forms as $form) : ?>
    42
     3<?php include_login_parts('Login', $form, 'member/login'); ?>
     4
     5<?php endforeach; ?>
  • OpenPNE3/trunk/apps/mobile_frontend/templates/_partsLogin.php

    r8598 r8757  
    55<?php include_customizes($id, 'top') ?>
    66
    7 <form action="<?php echo $link_to ?>" method="post">
     7<form action="<?php echo $link_to ?>" method="post"<?php if($form->isUtn()): ?> utn<?php endif; ?>>
    88<table>
    99<?php echo $form ?>
  • OpenPNE3/trunk/data/sns_config.yml

    r8714 r8757  
    2525  type:         "select"
    2626  choices_type: "AuthMode"
    27   default:      ["MobileAddress"]
     27  default:      ["MobileUID", "MobileAddress"]
    2828  option:
    2929    required: true
  • OpenPNE3/trunk/lib/form/sfOpenPNEAuthForm.class.php

    r8725 r8757  
    2222  public function configure()
    2323  {
    24     $this->widgetSchema->setNameFormat('auth[%s]');
    25     $this->addAuthModeField();
     24    $this->widgetSchema->setNameFormat('auth'.$this->getAuthMode().'[%s]');
    2625  }
    2726
     
    5756
    5857    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());
    6958  }
    7059
     
    130119    return $this->isValid();
    131120  }
     121
     122 /**
     123  * @todo removes this method.
     124  */
     125  public function isUtn()
     126  {
     127    return false;
     128  }
    132129}
  • OpenPNE3/trunk/lib/helper/PartsHelper.php

    r8567 r8757  
    2121{
    2222  $params = array(
    23     'id' => $id,
     23    'id' => $form->getAuthMode().$id,
    2424    'form' => $form,
    25     'link_to' => $link_to,
     25    'link_to' => url_for(sprintf($link_to.'?%s=%s', sfOpenPNEAuthForm::AUTH_MODE_FIELD_NAME, $form->getAuthMode())),
    2626  );
    2727  include_partial('global/partsLogin', $params);
  • OpenPNE3/trunk/lib/request/sfOpenPNEWebRequest.class.php

    r8713 r8757  
    1212  protected $userAgentMobileInstance = null;
    1313
    14   /**
    15    * @see sfWebRequest
    16    */
     14 /**
     15  * @see sfWebRequest
     16  */
    1717  public function initialize(sfEventDispatcher $dispatcher, $parameters = array(), $attributes = array())
    1818  {
     
    2020
    2121    require_once 'Net/UserAgent/Mobile.php';
    22     $this->userAgentMobileInstance = Net_UserAgent_Mobile::factory();
     22  }
     23
     24  public function getMobile()
     25  {
     26    if (!$this->userAgentMobileInstance) {
     27      $this->userAgentMobileInstance = Net_UserAgent_Mobile::factory();
     28    }
     29
     30    return $this->userAgentMobileInstance;
    2331  }
    2432
    2533  public function isMobile()
    2634  {
    27     return !($this->userAgentMobileInstance->isNonMobile());
     35    return !($this->getMobile()->isNonMobile());
     36  }
     37
     38 /**
     39  * Returns the mobile UID.
     40  *
     41  * @return string  mobile UID
     42  */
     43  public function getMobileUID()
     44  {
     45    if (!$this->isMobile()) {
     46      return false;
     47    }
     48
     49    $uid = $this->getMobile()->getUID();
     50    if (!$uid)
     51    {
     52      if ($this->getMobile()->isSoftBank())
     53      {
     54        $uid = $this->getMobile()->getSerialNumber();
     55      }
     56      elseif ($this->getMobile()->isDoCoMo())
     57      {
     58        $uid = $this->getMobile()->getCardID();
     59      }
     60    }
     61
     62    return $uid;
     63  }
     64
     65 /**
     66  * Checks whether the mobile UID is a valid or not.
     67  *
     68  * This method consideres the older versions of OpenPNE(-2.14).
     69  *
     70  * @params  string $hashedUid
     71  *
     72  * @return  bool
     73  */
     74  public function isValidMobileUID($hashedUid)
     75  {
     76    if (!$this->isMobile()) {
     77      return false;
     78    }
     79
     80    if ($hashedUid === md5($this->getMobile()->getUID()))
     81    {
     82      return true;
     83    }
     84
     85    if ($this->getMobile()->isSoftBank())
     86    {
     87      return ($hashedUid === md5($this->getMobile()->getSerialNumber()));
     88    }
     89
     90    if ($this->getMobile()->isDoCoMo())
     91    {
     92      return ($hashedUid === md5($this->getMobile()->getCardID()));
     93    }
     94
     95    return false;
    2896  }
    2997}
  • OpenPNE3/trunk/lib/user/sfOpenPNESecurityUser.class.php

    r8725 r8757  
    2222    parent::initialize($dispatcher, $storage, $options);
    2323
     24    $request = sfContext::getInstance()->getRequest();
     25    $authMode = $request->getUrlParameter('authMode');
     26
    2427    $authModes = $this->getAuthModes();
    25 
    26     $authMode = '';
    27 
    28     if (isset($_REQUEST['authMode']))
    29     {
    30       $authMode = $_REQUEST['authMode'];
    31     }
    3228
    3329    if (!$authMode || !in_array($authMode, $authModes))
  • OpenPNE3/trunk/plugins

    • Property svn:externals
      •  

        old new  
        22opAuthPCAddressPlugin https://trac.openpne.jp/svn/OpenPNE3/plugins/opAuthPCAddressPlugin/trunk
        33opAuthMobileAddressPlugin https://trac.openpne.jp/svn/OpenPNE3/plugins/opAuthMobileAddressPlugin/trunk
         4opAuthMobileUIDPlugin https://trac.openpne.jp/svn/OpenPNE3/plugins/opAuthMobileUIDPlugin/trunk
Note: See TracChangeset for help on using the changeset viewer.