Laravel AT Protocol Client (alpha & unstable)
1<?php
2
3namespace SocialDept\AtpClient\Exceptions;
4
5use Illuminate\Http\Request;
6use SocialDept\AtpClient\Enums\ScopeAuthorizationFailure;
7use Symfony\Component\HttpFoundation\Response;
8
9class 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}