Skip to content

Commit e24e608

Browse files
authored
支持 自定义模型绑定
app('jwt')->token([ 'uid' => $member->id, 'model' => CustomUser::class ]
1 parent e5020af commit e24e608

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/Service/User.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,12 @@ protected function resolveConfig(): array
4444

4545
public function getClass(): string
4646
{
47-
$store = $this->getStore();
48-
$class = $this->config->getClass();
49-
if (!$class) {
47+
$token = $this->app->get('jwt')->getToken();
48+
49+
try {
50+
$class = $token->getClaim('model', $this->config->getClass());
51+
} catch (\OutOfBoundsException $e) {
52+
$store = $this->getStore();
5053
throw new JWTException("{$store}应用未配置用户模型文件");
5154
}
5255

0 commit comments

Comments
 (0)