File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2020 "ext-mbstring" : " *" ,
2121 "lcobucci/jwt" : " 4.0.1" ,
2222 "nette/php-generator" : " ^3.2" ,
23- "topthink/framework" : " ^6.0"
23+ "topthink/framework" : " ^6.0" ,
24+ "xiaodi/think-user" : " 0.0.1"
2425 },
2526 "require-dev" : {
2627 "phpunit/phpunit" : " ^6.2" ,
Original file line number Diff line number Diff line change @@ -248,4 +248,14 @@ public function automaticRenewalToken(JwtToken $token)
248248
249249 return $ token ;
250250 }
251+
252+ public function getClaims ()
253+ {
254+ return $ this ->token ->claims ()->all ();
255+ }
256+
257+ public function getClaim ($ name )
258+ {
259+ return $ this ->token ->claims ()->get ($ name );
260+ }
251261}
Original file line number Diff line number Diff line change 77use think \App ;
88use xiaodi \JWTAuth \Config \User as Config ;
99use xiaodi \JWTAuth \Exception \JWTException ;
10+ use think \User \AuthorizationUserInterface ;
1011
1112class User
1213{
@@ -74,6 +75,10 @@ public function find()
7475 $ uid = $ token ->claims ()->get ('jti ' );
7576
7677 $ model = new $ class ();
77- return $ model ->find ($ uid );
78+ if ($ model instanceof AuthorizationUserInterface) {
79+ return $ model ->getUserById ($ uid );
80+ } else {
81+ throw new JWTException ('implements ' . AuthorizationUserInterface::class);
82+ }
7883 }
7984}
You can’t perform that action at this time.
0 commit comments