Skip to content

Commit 0bd6cb6

Browse files
committed
🐛 Fixes session flash key name
Ensures the session flash key for the OAuth state is configurable. This change introduces a `stateSessionSlug` property, allowing customization of the session key used to store the OAuth state, improving flexibility and avoiding potential naming conflicts.
1 parent 20c7f42 commit 0bd6cb6

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

packages/auth/src/OAuth/OAuthManager.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@
1414
use function Tempest\get;
1515
use function Tempest\Support\str;
1616

17-
final readonly class OAuthManager
17+
final class OAuthManager
1818
{
19+
public private(set) string $stateSessionSlug = 'oauth-state';
20+
1921
public function __construct(
20-
private OAuth2Provider $provider,
21-
private HttpClient $httpClient,
22-
private Session $session,
22+
private readonly OAuth2Provider $provider,
23+
private readonly HttpClient $httpClient,
24+
private readonly Session $session,
2325
) {}
2426

2527
public function generateAuthorizationUrl(
@@ -34,7 +36,7 @@ public function generateAuthorizationUrl(
3436
$state = $this->generateState();
3537

3638
$parameters['state'] = $state;
37-
$this->session->flash('oauth-state', $state);
39+
$this->session->flash($this->stateSessionSlug, $state);
3840
}
3941

4042
$queryString = http_build_query(array_filter($parameters), arg_separator: '&');

0 commit comments

Comments
 (0)