Esempio n. 1
0
 /** @inheritdoc */
 public function validate(array $data = [], $throwException = true)
 {
     if (empty($data)) {
         $data = $this->attributes;
     }
     if (parent::validate($data)) {
         $userId = ArrayUtils::get($data, 'user_id');
         $appId = ArrayUtils::get($data, 'app_id');
         if ($userId && $appId) {
             $model = $this->whereAppId($appId)->whereUserId($userId)->first();
             if (!empty($model) && $model->id !== ArrayUtils::get($data, 'id')) {
                 throw new BadRequestException('Multiple user-to-app-to-role assignment. You can only have a single user-to-app-to-role assignment.');
             }
         }
         return true;
     }
     return false;
 }
Esempio n. 2
0
 public function validate(array $data = [], $throwException = true)
 {
     if (empty($data)) {
         $data = $this->attributes;
     }
     if (!empty($disable = config('df.scripting.disable'))) {
         switch (strtolower($disable)) {
             case 'all':
                 throw new ServiceUnavailableException("All scripting is disabled for this instance.");
                 break;
             default:
                 $type = isset($data['type']) ? $data['type'] : null;
                 if (!empty($type) && false !== stripos($disable, $type)) {
                     throw new ServiceUnavailableException("Scripting with {$type} is disabled for this instance.");
                 }
                 break;
         }
     }
     return parent::validate($data, $throwException);
 }