public function beforeSave($insert)
 {
     if ($this->isNewRecord) {
         $this->password = md5($this->password);
     } else {
         $this->username = $this->getOldAttribute("username");
         $this->email = $this->getOldAttribute("email");
         $this->social_type = $this->getOldAttribute("social_type");
     }
     return parent::beforeSave($insert);
 }
 public function afterSave($insert, $changedAttributes)
 {
     //寫入權限
     $this->revokeRole();
     $auth = Yii::$app->authManager;
     $_role = $auth->getRole($this->role);
     $auth->assign($_role, $this->id);
     return parent::afterSave($insert, $changedAttributes);
 }