|
7 | 7 |
|
8 | 8 | use Illuminate\Http\Request;
|
9 | 9 | use Laravel\Passport\ClientRepository;
|
| 10 | +use Laravel\Passport\Exceptions\AuthenticationException; |
10 | 11 | use Laravel\Passport\Http\Controllers\AuthorizationController as PassportAuthorizationController;
|
11 | 12 | use Laravel\Passport\Passport;
|
12 | 13 | use Laravel\Passport\TokenRepository;
|
@@ -35,21 +36,17 @@ public function authorize(
|
35 | 36 | ClientRepository $clients,
|
36 | 37 | TokenRepository $tokens
|
37 | 38 | ) {
|
38 |
| - $redirectUri = presence(trim(get_string($request['redirect_uri']) ?? '')); |
39 |
| - |
40 |
| - abort_if($redirectUri === null, 400, osu_trans('model_validation.required', ['attribute' => 'redirect_uri'])); |
41 |
| - |
42 |
| - if (!auth()->check()) { |
43 |
| - // Breaks when url contains hash ("#"). |
44 |
| - $separator = strpos($redirectUri, '?') === false ? '?' : '&'; |
45 |
| - $cancelUrl = "{$redirectUri}{$separator}error=access_denied"; |
| 39 | + try { |
| 40 | + return parent::authorize($this->normalizeRequestScopes($psrRequest), $request, $clients, $tokens); |
| 41 | + } catch (AuthenticationException $_e) { |
| 42 | + $cancelUrl = $request->fullUrl(); |
| 43 | + $cancelUrl .= strpos($cancelUrl, '?') === false ? '?' : '&'; |
| 44 | + $cancelUrl .= 'prompt=none'; |
46 | 45 |
|
47 | 46 | return ext_view('sessions.create', [
|
48 | 47 | 'cancelUrl' => $cancelUrl,
|
49 | 48 | ]);
|
50 | 49 | }
|
51 |
| - |
52 |
| - return parent::authorize($this->normalizeRequestScopes($psrRequest), $request, $clients, $tokens); |
53 | 50 | }
|
54 | 51 |
|
55 | 52 | /**
|
|
0 commit comments