| 123456789101112131415161718192021222324252627282930313233 |
- <?php
- namespace App\Module\User\Validator;
- use App\Module\AppGame\SessionApp;
- use UCore\Exception\LogicException;
- use UCore\Validator;
- /**
- * 用户ID注入
- *
- */
- class UserIdValidator extends Validator
- {
- public function validate(mixed $value, array $data): bool
- {
- // 必须在app下
- $s3name = substr(request()->getPathInfo(),1,3);
- if($s3name !== 'app'){
- throw new LogicException("代码错误-1");
- }
- $user_id = SessionApp::getUserId();
- $this->validation->setRaw('user_id', $user_id);
- //
- return true;
- }
- }
|