リビジョン 8b8631af app/Model/User.php
| app/Model/User.php | ||
|---|---|---|
| 19 | 19 |
*/ |
| 20 | 20 |
public $validate = array( |
| 21 | 21 |
'login_id' => array( |
| 22 |
'notBlank' => array( |
|
| 23 | 22 |
'rule' => array('notBlank'),
|
| 24 |
//'message' => 'Your custom message here', |
|
| 25 |
//'allowEmpty' => false, |
|
| 26 |
//'required' => false, |
|
| 27 |
//'last' => false, // Stop validation after this rule |
|
| 28 |
//'on' => 'create', // Limit validation to 'create' or 'update' operations |
|
| 23 |
'message' => 'この項目は入力必須です' |
|
| 29 | 24 |
), |
| 30 |
), |
|
| 31 | 25 |
'email' => array( |
| 26 |
array( |
|
| 27 |
'rule' => array('notBlank'),
|
|
| 28 |
'message' => 'メールアドレスを入力してください' |
|
| 29 |
), |
|
| 32 | 30 |
// メールアドレスであること。 |
| 33 |
'validEmail' => array( 'rule' => array( 'email', true), 'message' => 'アドレスを入力して下さい'), |
|
| 31 |
'isEmail' => array( |
|
| 32 |
'rule' => 'Email', |
|
| 33 |
'message' => '正しいメールアドレスを入力してください' |
|
| 34 |
), |
|
| 35 |
array( |
|
| 36 |
'rule' => 'DuplicateEmailCheck', |
|
| 37 |
'message' => 'このメールアドレスは既に登録されています' |
|
| 38 |
), |
|
| 34 | 39 |
// 一意性チェック |
| 35 | 40 |
// 'emailExists' => array( 'rule' => 'isUnique', 'message' => '既に登録されています'), |
| 36 | 41 |
), |
| 37 | 42 |
'password' => array( |
| 38 |
// パスワード・確認用パスワードの一致 |
|
| 39 |
'match' => array( 'rule' => array( 'confirmPassword', 'password_confirm'), 'message' => '一致しません'), |
|
| 43 |
array( |
|
| 44 |
'rule' => array('notBlank'),
|
|
| 45 |
'message' => 'パスワードを入力してください' |
|
| 46 |
), |
|
| 47 |
array( |
|
| 48 |
'rule' => array('minLength', 8),
|
|
| 49 |
'message' => 'パスワードは8文字以上入力してください', |
|
| 50 |
), |
|
| 51 |
array( |
|
| 52 |
'rule' => 'passwordConfirm', |
|
| 53 |
'message' => 'パスワードが一致していません' |
|
| 54 |
), |
|
| 55 |
), |
|
| 56 |
'password_confirm' => array( |
|
| 57 |
array( |
|
| 58 |
'rule' => array('notBlank'),
|
|
| 59 |
'message' => 'パスワード(確認)を入力してください' |
|
| 60 |
), |
|
| 40 | 61 |
), |
| 41 |
// 'password' => array( |
|
| 42 |
// 'notBlank' => array( |
|
| 43 |
// 'rule' => array('notBlank'),
|
|
| 44 |
// //'message' => 'Your custom message here', |
|
| 45 |
// //'allowEmpty' => false, |
|
| 46 |
// //'required' => false, |
|
| 47 |
// //'last' => false, // Stop validation after this rule |
|
| 48 |
// //'on' => 'create', // Limit validation to 'create' or 'update' operations |
|
| 49 |
// ), |
|
| 50 |
// ), |
|
| 51 | 62 |
'status' => array( |
| 52 | 63 |
'numeric' => array( |
| 53 | 64 |
'rule' => array('numeric'),
|
| ... | ... | |
| 61 | 72 |
); |
| 62 | 73 |
|
| 63 | 74 |
|
| 75 |
public function DuplicateEmailCheck(){
|
|
| 76 |
$query = array('conditions' => array('User.email' => $this->data['User']['email'],'User.status' => 1));
|
|
| 77 |
$num = $this->find('count',$query);
|
|
| 78 |
//$this->log($recodes); |
|
| 79 |
//var_dump($num); |
|
| 80 |
//exit; |
|
| 81 |
if($num > 0){
|
|
| 82 |
return false; //登録済み |
|
| 83 |
} else{
|
|
| 84 |
return true; //未登録 |
|
| 85 |
} |
|
| 86 |
} |
|
| 64 | 87 |
|
| 65 |
public function confirmPassword( $field, $password_confirm) {
|
|
| 66 |
if ($field['password'] === $this->data[$this->name][$password_confirm]) {
|
|
| 88 |
public function passwordConfirm($check){
|
|
| 89 |
//2つのパスワードフィールドが一致する事を確認する |
|
| 90 |
if($this->data['User']['password'] === $this->data['User']['password_confirm']){
|
|
| 67 | 91 |
// パスワードハッシュ化 |
| 68 |
$this->data[$this->name]['password'] = Security::hash( $plain, 'sha512', true);
|
|
| 92 |
$this->data[$this->name]['password'] = Security::hash( $password, 'sha512', true);
|
|
| 69 | 93 |
return true; |
| 94 |
}else{
|
|
| 95 |
return false; |
|
| 70 | 96 |
} |
| 97 |
|
|
| 71 | 98 |
} |
| 72 | 99 |
|
| 100 |
|
|
| 73 | 101 |
public function getActivationHash() {
|
| 74 | 102 |
// ユーザIDの有無確認 |
| 75 | 103 |
if (!isset($this->id)) {
|
他の形式にエクスポート: Unified diff