リビジョン 04e657a7 app/Model/User.php
| app/Model/User.php | ||
|---|---|---|
| 28 | 28 |
//'on' => 'create', // Limit validation to 'create' or 'update' operations |
| 29 | 29 |
), |
| 30 | 30 |
), |
| 31 |
'password' => array( |
|
| 32 |
'notBlank' => array( |
|
| 33 |
'rule' => array('notBlank'),
|
|
| 34 |
//'message' => 'Your custom message here', |
|
| 35 |
//'allowEmpty' => false, |
|
| 36 |
//'required' => false, |
|
| 37 |
//'last' => false, // Stop validation after this rule |
|
| 38 |
//'on' => 'create', // Limit validation to 'create' or 'update' operations |
|
| 39 |
), |
|
| 40 |
), |
|
| 31 |
'email' => array( |
|
| 32 |
// メールアドレスであること。 |
|
| 33 |
'validEmail' => array( 'rule' => array( 'email', true), 'message' => 'アドレスを入力して下さい'), |
|
| 34 |
// 一意性チェック |
|
| 35 |
// 'emailExists' => array( 'rule' => 'isUnique', 'message' => '既に登録されています'), |
|
| 36 |
), |
|
| 37 |
'password' => array( |
|
| 38 |
// パスワード・確認用パスワードの一致 |
|
| 39 |
'match' => array( 'rule' => array( 'confirmPassword', 'password_confirm'), 'message' => '一致しません'), |
|
| 40 |
), |
|
| 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 |
// ), |
|
| 41 | 51 |
'status' => array( |
| 42 | 52 |
'numeric' => array( |
| 43 | 53 |
'rule' => array('numeric'),
|
| ... | ... | |
| 51 | 61 |
); |
| 52 | 62 |
|
| 53 | 63 |
|
| 64 |
|
|
| 65 |
public function confirmPassword( $field, $password_confirm) {
|
|
| 66 |
if ($field['password'] === $this->data[$this->name][$password_confirm]) {
|
|
| 67 |
// パスワードハッシュ化 |
|
| 68 |
$this->data[$this->name]['password'] = Security::hash( $plain, 'sha512', true); |
|
| 69 |
return true; |
|
| 70 |
} |
|
| 71 |
} |
|
| 72 |
|
|
| 73 |
public function getActivationHash() {
|
|
| 74 |
// ユーザIDの有無確認 |
|
| 75 |
if (!isset($this->id)) {
|
|
| 76 |
return false; |
|
| 77 |
} |
|
| 78 |
// 更新日時をハッシュ化 |
|
| 79 |
return Security::hash( $this->field('updated'), 'md5', true);
|
|
| 80 |
} |
|
| 81 |
|
|
| 82 |
|
|
| 54 | 83 |
public function beforeSave($options = array()) {
|
| 55 | 84 |
if (isset($this->data[$this->alias]['password'])) {
|
| 56 | 85 |
$passwordHasher = new BlowfishPasswordHasher(); |
他の形式にエクスポート: Unified diff