Skip to content

Commit a07ed34

Browse files
authored
Merge pull request #4 from designmynight/route-caching
refactor: don't use callback for route action to ensure routes can be…
2 parents a4674d1 + 4baa9f2 commit a07ed34

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

routes/routes.php

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
11
<?php
22

3+
use DesignMyNight\Laravel\OAuth2\Http\Controllers\RedirectImplicitGrant;
4+
35
/**
46
* Redirecting endpoint for initiating the OAuth2 Implicit Grant flow.
57
* The retrieved access token can be used to call the APIs as protected with the provided middleware.
68
*
79
* Note: this module does not provide any logic for extracting the access tokens from the url.
810
*
911
*/
10-
Route::get('/redirect', function (Request $request) {
11-
$query = http_build_query([
12-
'client_id' => config('authorizationserver.client_id'),
13-
'redirect_uri' => config('authorizationserver.redirect_url'),
14-
'response_type' => 'token',
15-
'scope' => 'place-orders',
16-
]);
17-
18-
return redirect(config('authorizationserver.authorization_url') . '?' . $query);
19-
});
12+
Route::get('/redirect', RedirectImplicitGrant::class);
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
namespace DesignMyNight\Laravel\OAuth2\Http\Controllers;
4+
5+
use Illuminate\Routing\Controller;
6+
7+
class RedirectImplicitGrant extends Controller
8+
{
9+
public function __invoke()
10+
{
11+
$query = http_build_query([
12+
'client_id' => config('authorizationserver.client_id'),
13+
'redirect_uri' => config('authorizationserver.redirect_url'),
14+
'response_type' => 'token',
15+
'scope' => 'place-orders',
16+
]);
17+
18+
return redirect(config('authorizationserver.authorization_url') . '?' . $query);
19+
}
20+
}

0 commit comments

Comments
 (0)