Improve scope checking
Whether the scopes are defined as a space separated string, or an array, we should now be checking them without any errors.
This commit is contained in:
parent
55afa8f01d
commit
baee7ade4f
3 changed files with 29 additions and 7 deletions
|
@ -51,7 +51,11 @@ class MicropubMediaController extends Controller
|
|||
return $micropubResponses->tokenHasNoScopeResponse();
|
||||
}
|
||||
|
||||
if (Str::contains($tokenData->claims()->get('scope'), 'create') === false) {
|
||||
$scopes = $tokenData->claims()->get('scope');
|
||||
if (is_string($scopes)) {
|
||||
$scopes = explode(' ', $scopes);
|
||||
}
|
||||
if (!in_array('create', $scopes)) {
|
||||
$micropubResponses = new MicropubResponses();
|
||||
|
||||
return $micropubResponses->insufficientScopeResponse();
|
||||
|
@ -119,7 +123,11 @@ class MicropubMediaController extends Controller
|
|||
return $micropubResponses->tokenHasNoScopeResponse();
|
||||
}
|
||||
|
||||
if (Str::contains($tokenData->claims()->get('scope'), 'create') === false) {
|
||||
$scopes = $tokenData->claims()->get('scope');
|
||||
if (is_string($scopes)) {
|
||||
$scopes = explode(' ', $scopes);
|
||||
}
|
||||
if (!in_array('create', $scopes)) {
|
||||
$micropubResponses = new MicropubResponses();
|
||||
|
||||
return $micropubResponses->insufficientScopeResponse();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue