Exemple #1
0
 /**
  * Finds the Tenant model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Tenant the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Tenant::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 /**
  * @param string $userId
  * @return mixed
  */
 public function actionRemoveTenant($userId, $tenantId = null)
 {
     if (!isset($tenantId)) {
         $tenant = Yii::$app->tenant->identity;
     } else {
         $tenant = Tenant::findOne($tenantId);
     }
     $model = ApiUser::findOne($userId);
     if ($model) {
         $data = ['app_metadata' => $model['app_metadata']];
         unset($data['app_metadata']['permissions'][Yii::$app->getModule('auth0')->serviceId][$tenant->name]);
         if ($this->update($userId, $data)) {
             $user = User::findByAuth0($model);
             $tenantUser = TenantUser::findByTenantUser($tenant, $user);
             $tenantUser->delete();
             $msg = 'Successfully removed the selected user from the current tenant';
             return $this->goBack();
         }
     }
     throw new HttpException(404, 'The requested user cannot be found.');
 }
Exemple #3
0
 /**
  * @return mixed
  */
 public static function getIdentity()
 {
     return TenantModel::findOne(Yii::$app->session->get('user.tenantId'));
 }
Exemple #4
0
 /**
  * @return mixed
  */
 public function getTenant()
 {
     return Tenant::findOne($this->tenant_id);
 }