File tree Expand file tree Collapse file tree 1 file changed +24
-3
lines changed Expand file tree Collapse file tree 1 file changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -60,7 +60,12 @@ public static function fromPsrRequest(ServerRequestInterface $request): static
6060 */
6161 public function can (string $ scope ): bool
6262 {
63- return in_array ('* ' , $ this ->oauth_scopes ) || $ this ->scopeExistsIn ($ scope , $ this ->oauth_scopes );
63+ if (empty ($ this ->attributes ['oauth_scopes ' ])) {
64+ return false ;
65+ }
66+
67+ return in_array ('* ' , $ this ->attributes ['oauth_scopes ' ])
68+ || $ this ->scopeExistsIn ($ scope , $ this ->attributes ['oauth_scopes ' ]);
6469 }
6570
6671 /**
@@ -84,15 +89,31 @@ public function transient(): bool
8489 */
8590 public function revoke (): bool
8691 {
87- return (bool ) Passport::token ()->newQuery ()->whereKey ($ this ->oauth_access_token_id )->update (['revoked ' => true ]);
92+ if ($ this ->token ) {
93+ return $ this ->token ->revoke ();
94+ }
95+
96+ if (isset ($ this ->attributes ['oauth_access_token_id ' ])) {
97+ return (bool ) Passport::token ()->newQuery ()->whereKey ($ this ->attributes ['oauth_access_token_id ' ])->update (['revoked ' => true ]);
98+ }
99+
100+ return false ;
88101 }
89102
90103 /**
91104 * Get the token instance.
92105 */
93106 protected function getToken (): ?Token
94107 {
95- return $ this ->token ??= Passport::token ()->newQuery ()->find ($ this ->oauth_access_token_id );
108+ if ($ this ->token ) {
109+ return $ this ->token ;
110+ }
111+
112+ if (isset ($ this ->attributes ['oauth_access_token_id ' ])) {
113+ return $ this ->token = Passport::token ()->newQuery ()->find ($ this ->attributes ['oauth_access_token_id ' ]);
114+ }
115+
116+ return null ;
96117 }
97118
98119 /**
You can’t perform that action at this time.
0 commit comments