Example #1
0
 public function beforeSave($insert)
 {
     if (parent::beforeSave($insert)) {
         if ($this->isNewRecord) {
             $this->auth_key = Yii::$app->getSecurity()->generateRandomString();
         }
         return true;
     }
     return false;
 }
Example #2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getUser()
 {
     return $this->hasOne(User::className(), ['id' => 'user_id']);
 }
Example #3
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();
 }
Example #4
0
 /**
  * @inheritdoc
  */
 public function attributeLabels()
 {
     return ArrayHelper::merge(parent::attributeLabels(), ['repeatPassword' => Yii::t('app', 'Repeat Password')]);
 }
Example #5
0
 public function beforeSave($insert)
 {
     if (parent::beforeSave($insert)) {
         if ($insert) {
             $this->generateAuthKey();
         }
         return true;
     }
     return false;
 }