Skip to content

Instantly share code, notes, and snippets.

@jamband
Last active September 28, 2015 10:38
Show Gist options
  • Select an option

  • Save jamband/1426237 to your computer and use it in GitHub Desktop.

Select an option

Save jamband/1426237 to your computer and use it in GitHub Desktop.
<?php
class User extends CActiveRecord
{
public $password2;
...
public function rules()
{
return array(
...
array('password', 'compare', 'compareAttribute'=>'password2', 'message'=>'{attribute} とパスワード(確認)が一致しません。', 'on'=>'register'),
...
);
}
protected function beforeSave()
{
$ph = new PasswordHash(
Yii::app()->params['iteration_count_log2'],
Yii::app()->params['portable_hashes']
);
$this->password = $ph->HashPassword($this->password);
...
return parent::beforeSave();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment