Laravel AT Protocol Client (alpha & unstable)
3
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add ScopeAuthorizationException

+26
+26
src/Exceptions/ScopeAuthorizationException.php
··· 1 + <?php 2 + 3 + namespace SocialDept\AtpClient\Exceptions; 4 + 5 + use Illuminate\Http\Request; 6 + use SocialDept\AtpClient\Enums\ScopeAuthorizationFailure; 7 + use Symfony\Component\HttpFoundation\Response; 8 + 9 + class ScopeAuthorizationException extends MissingScopeException 10 + { 11 + /** 12 + * Render the exception as an HTTP response. 13 + */ 14 + public function render(Request $request): Response 15 + { 16 + $action = config('atp-client.scope_authorization.failure_action', ScopeAuthorizationFailure::Abort); 17 + 18 + return match ($action) { 19 + ScopeAuthorizationFailure::Redirect => redirect( 20 + config('atp-client.scope_authorization.redirect_to', '/login') 21 + ), 22 + ScopeAuthorizationFailure::Exception => throw $this, 23 + default => abort(403, $this->getMessage()), 24 + }; 25 + } 26 + }