Пример #1
0
 public function beforeSave($insert)
 {
     if (parent::beforeSave($insert)) {
         if ($this->isNewRecord) {
             $this->auth_key = Yii::$app->getSecurity()->generateRandomString();
         }
         return true;
     }
     return false;
 }
Пример #2
0
 public function beforeSave($insert)
 {
     parent::beforeSave($insert);
     if ($this->password) {
         $this->hash = \Yii::$app->security->generatePasswordHash($this->password);
     }
     if ($this->isNewRecord && !$this->activation_code) {
         $this->activation_code = md5(\Yii::$app->security->generateRandomString());
     }
     if ($this->isNewRecord && !$this->access_token) {
         $this->access_token = self::generateToken();
     }
     return !$this->hasErrors();
 }
Пример #3
0
 public function beforeSave($insert)
 {
     if (parent::beforeSave($insert)) {
         if ($insert) {
             $this->generateAuthKey();
         }
         return true;
     }
     return false;
 }