예제 #1
0
파일: User.php 프로젝트: jarrus90/yii2-user
 /** @inheritdoc */
 public function beforeSave($insert)
 {
     if ($insert) {
         $this->setAttribute('auth_key', Yii::$app->security->generateRandomString());
         if (Yii::$app instanceof WebApplication) {
             $this->setAttribute('registration_ip', Yii::$app->request->userIP);
         }
     }
     if (!empty($this->password)) {
         $this->setAttribute('password_hash', Password::hash($this->password));
     }
     if (empty($this->lang)) {
         $this->setAttribute('lang', Yii::$app->language);
     }
     return parent::beforeSave($insert);
 }