Project

General

Profile

Backport(バックポート) #2607

3.6RC1以降、仮登録時にメールアドレスが登録されないと新規登録がおこなえない

Added by Kousuke Ebihara almost 8 years ago. Updated almost 8 years ago.

Status:
Fixed(完了)
Priority:
Urgent(急いで)
Assignee:
Target version:
Start date:
2011-11-08
Due date:
% Done:

100%


Description

Overview (現象)

OpenPNE 3.6RC1 〜 のバージョンだと、仮登録時にメールアドレスが登録されないと新規登録が404エラーとなり、メンバー登録を完了できない。

メンバー登録がおこなえない例

opAuthOpenIDPlugin を利用していて、OpenIDプロバイダ側からメールアドレスが共有されない場合

現象確認バージョン

OpenPNE 3.6.0 (OpenPNE 3.6beta14 では発生せず)

Causes (原因)

Way to fix (修正内容)


Related issues

Related to OpenPNE 3 - Bug(バグ) #2588: 3.6RC1以降、仮登録時にメールアドレスが登録されないと新規登録がおこなえない Fixed(完了) 2011-11-08

Associated revisions

Revision 91f2bbfc (diff)
Added by Yuya Watanabe almost 8 years ago

(fixes #2607, BP from #2588) fixed to validate token when auth plugin is mail address

History

#1 Updated by Yuya Watanabe almost 8 years ago

  • Assignee set to Yuya Watanabe

#2 Updated by Yuya Watanabe almost 8 years ago

修正案

下記修正案はプラグインに依存してしまうので最善ではない.そのためバックポート元にはこの記述を行なっていない.
また, 処理の順番などを加味するとリファクタリングが必要なのではないかと思われる.
簡単な動作確認を行ったところ問題はなかった.

diff --git a/lib/model/doctrine/MemberTable.class.php b/lib/model/doctrine/MemberTable.class.php
index 4ec3816..59766f4 100644
--- a/lib/model/doctrine/MemberTable.class.php
+++ b/lib/model/doctrine/MemberTable.class.php
@@ -153,7 +153,7 @@ class MemberTable extends opAccessControlDoctrineTable
     return $this->findInactive($config->getMemberId());
   }

-  public function findByValidRegisterToken($token)
+  public function findByValidRegisterToken($token, $authType)
   {
     $member = $this->findByRegisterToken($token);
     if (!$member)
@@ -161,6 +161,11 @@ class MemberTable extends opAccessControlDoctrineTable
       return false;
     }

+    if (!$authType || 'MailAddress' !== $authType)
+    {
+      return $member;
+    }
+
     $configTable = Doctrine::getTable('MemberConfig');

     $mailTypes = array("pc_address", "pc_address_pre", "mobile_address", "mobile_address_pre");
diff --git a/lib/user/opSecurityUser.class.php b/lib/user/opSecurityUser.class.php
index be67cc6..d013c1e 100644
--- a/lib/user/opSecurityUser.class.php
+++ b/lib/user/opSecurityUser.class.php
@@ -417,7 +417,7 @@ class opSecurityUser extends opAdaptableUser

   public function setRegisterToken($token)
   {
-    $member = Doctrine::getTable('Member')->findByValidRegisterToken($token);
+    $member = Doctrine::getTable('Member')->findByValidRegisterToken($token, $this->getAuthAdapter()->getAuthModeName());
     if (!$member)
     {
       return false;

#3 Updated by Yuya Watanabe almost 8 years ago

修正案2

  • opAuthMailAddressPluginに依存しない実装にした場合に変更しなければならない部分を減らすために$mailTypesをより呼び出し側に近いところに持ってきた.
  • findByValidRegisterToken()をMemberConfig名群について最新のregister_tokenを持っているかどうかを調べる汎用的なメソッドに修正した.
  • findByValidRegisterToken()内で必要とするデータはすべてMemberConfigTableであるが,findByRegisterToken()がMemberTable内にあるため本修正案ではクラスをまたいだメソッドの移動は採用していない.
diff --git a/lib/model/doctrine/MemberTable.class.php b/lib/model/doctrine/MemberTable.class.php
index 4ec3816..8ad8a28 100644
--- a/lib/model/doctrine/MemberTable.class.php
+++ b/lib/model/doctrine/MemberTable.class.php
@@ -153,21 +153,19 @@ class MemberTable extends opAccessControlDoctrineTable
     return $this->findInactive($config->getMemberId());
   }

-  public function findByValidRegisterToken($token)
+  public function findByValidRegisterToken($token, $configNames)
   {
     $member = $this->findByRegisterToken($token);
     if (!$member)
     {
       return false;
     }
-
     $configTable = Doctrine::getTable('MemberConfig');

-    $mailTypes = array("pc_address", "pc_address_pre", "mobile_address", "mobile_address_pre");
     $query = $configTable->createQuery('m');
-    foreach ($mailTypes as $mailType)
+    foreach ($configNames as $configName)
     {
-      $hash = $configTable->generateNameValueHash($mailType, $member->getConfig($mailType));
+      $hash = $configTable->generateNameValueHash($configName, $member->getConfig($configName));
       $query->orWhere('m.name_value_hash = ?', $hash);
     }
     $configs = $query->fetchArray();
diff --git a/lib/user/opSecurityUser.class.php b/lib/user/opSecurityUser.class.php
index be67cc6..60ff898 100644
--- a/lib/user/opSecurityUser.class.php
+++ b/lib/user/opSecurityUser.class.php
@@ -417,7 +417,15 @@ class opSecurityUser extends opAdaptableUser

   public function setRegisterToken($token)
   {
-    $member = Doctrine::getTable('Member')->findByValidRegisterToken($token);
+    if ('MailAddress' === $this->getAuthAdapter()->getAuthModeName())
+    {
+      $mailTypes = array("pc_address", "pc_address_pre", "mobile_address", "mobile_address_pre");
+      $member = Doctrine::getTable('Member')->findByValidRegisterToken($token, $mailTypes);
+    }
+    else
+    {
+      $member = Doctrine::getTable('Member')->findByRegisterToken($token);
+    }
     if (!$member)
     {
       return false;

#4 Updated by Yuya Watanabe almost 8 years ago

  • Status changed from New(新規) to Pending Review(レビュー待ち)
  • % Done changed from 0 to 50

更新履歴 91f2bbfc9e8bf50d6fb4283fba7ccc23fae5e045 で適用されました。

#5 Updated by Kousuke Ebihara almost 8 years ago

  • Status changed from Pending Review(レビュー待ち) to Pending Testing(テスト待ち)
  • % Done changed from 50 to 70

#6 Updated by Yuma Sakata almost 8 years ago

  • Status changed from Pending Testing(テスト待ち) to Fixed(完了)
  • % Done changed from 70 to 100

テストOKです。

Also available in: Atom PDF