commit 67acbfb5a6ac42591b4c6bf3cf2b5fac97b78796
Author: hasse <hasegawa@i-hearts.jp>
Date:   Wed Mar 9 21:07:37 2016 -0500

    パスワード再発行機能実装

diff --git a/app/Model/User.php b/app/Model/User.php
index 944e56e..7c6022e 100755
--- a/app/Model/User.php
+++ b/app/Model/User.php
@@ -39,6 +39,18 @@ class User extends AppModel {
             // 一意性チェック
             // 'emailExists' => array( 'rule' => 'isUnique', 'message' => '既に登録されています'),
         ),
+        'email_confirm' => array(
+            array(
+				'rule' => array('notBlank'),
+                'message' => 'メールアドレス(確認)を入力してください'
+            ), 
+            array(
+                'rule' => 'emailConfirm', 
+                'message' => 'メールアドレスが一致していません'
+            ), 
+
+        ),
+
         'password' => array(
             array(
 				'rule' => array('notBlank'),
@@ -71,7 +83,79 @@ class User extends AppModel {
 		),
 	);
 
+	public $reset_pwd_validate = array(
+        'email' => array(
+        	array(
+				'rule' => array('notBlank'),
+                'message' => 'メールアドレスを入力してください'
+            ),
+            // メールアドレスであること。
+            'isEmail' => array( 
+				'rule' => 'Email',
+            	'message' => '正しいメールアドレスを入力してください'
+            ),
+            array(
+                'rule' => 'emailConfirm', 
+                'message' => 'メールアドレスが一致していません'
+            ), 
+            array(
+                'rule' => 'NotExistEmailCheck', 
+                'message' => 'このメールアドレスは登録されていません'
+            ), 
 
+        ),
+        'email_confirm' => array(
+            array(
+				'rule' => array('notBlank'),
+                'message' => 'メールアドレス(確認)を入力してください'
+            ), 
+
+        ),
+
+        'password' => array(
+            array(
+				'rule' => array('notBlank'),
+                'message' => 'パスワードを入力してください'
+            ), 
+            array(
+                'rule' => array('minLength', 8), 
+                'message' => 'パスワードは8文字以上入力してください', 
+            ),
+            array(
+                'rule' => 'passwordConfirm', 
+                'message' => 'パスワードが一致していません'
+            ), 
+        ),
+        'password_confirm' => array(
+            array(
+				'rule' => array('notBlank'),
+                'message' => 'パスワード(確認)を入力してください'
+            ), 
+        ),
+	);
+	public $new_pwd_validate = array(
+
+        'password' => array(
+            array(
+				'rule' => array('notBlank'),
+                'message' => 'パスワードを入力してください'
+            ), 
+            array(
+                'rule' => array('minLength', 8), 
+                'message' => 'パスワードは8文字以上入力してください', 
+            ),
+            array(
+                'rule' => 'passwordConfirm', 
+                'message' => 'パスワードが一致していません'
+            ), 
+        ),
+        'password_confirm' => array(
+            array(
+				'rule' => array('notBlank'),
+                'message' => 'パスワード(確認)を入力してください'
+            ), 
+        ),
+	);
 	public function DuplicateEmailCheck(){
 		$query = array('conditions' => array('User.email' => $this->data['User']['email'],'User.status' => 1));
 		$num = $this->find('count',$query);
@@ -95,6 +179,15 @@ class User extends AppModel {
 
     }
 
+    public function emailConfirm($check){
+        //２つのパスワードフィールドが一致する事を確認する
+        if($this->data['User']['email'] === $this->data['User']['email_confirm']){
+            return true;
+        }else{
+            return false;
+        }
+
+    }
 
 	public function getActivationHash() {
 	    // ユーザIDの有無確認
@@ -106,6 +199,20 @@ class User extends AppModel {
 	}
 
 
+	//メールアドレスが登録されていない、またはメールアドレスのstatusが１ではない場合、エラーを出す
+	public function NotExistEmailCheck(){
+		$query = array('conditions' => array('User.email' => $this->data['User']['email'],'User.status' => 1));
+		$num = $this->find('count',$query);
+		//$this->log($recodes);
+		//var_dump($num);
+		//exit;
+		if($num > 0){
+            return true;	//未登録
+		} else{
+            return false;	//登録済み
+		}
+	}
+
 	public function beforeSave($options = array()) {
 	    if (isset($this->data[$this->alias]['password'])) {
 	        $passwordHasher = new BlowfishPasswordHasher();
