Skip to content

Commit 871c31f

Browse files
Use add auth param to add login hint (#25)
1 parent 5d16d11 commit 871c31f

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

src/OpenIDConnectClient.php

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ class OpenIDConnectClient extends \Jumbojett\OpenIDConnectClient
1919
{
2020
protected ?JweDecryptInterface $jweDecrypter;
2121
protected ?OpenIDConfiguration $openIDConfiguration;
22-
protected ?string $loginHint = null;
2322

2423
public function __construct(
2524
?string $providerUrl = null,
@@ -122,12 +121,11 @@ protected function getWellKnownConfigValue($param, $default = null): string|arra
122121
*/
123122
public function setLoginHint(?string $loginHint = null): void
124123
{
125-
$this->loginHint = $loginHint;
124+
$this->addAuthParam(['login_hint' => $loginHint]);
126125
}
127126

128127
/**
129128
* Overwrite the redirect method to a redirect method of Laravel.
130-
* And add login_hint when redirecting to the authorization endpoint.
131129
* Sometimes the error 'Cannot modify header information - headers already sent' was thrown.
132130
* By using HttpResponseException, laravel will return the given response.
133131
* @param string $url
@@ -136,14 +134,6 @@ public function setLoginHint(?string $loginHint = null): void
136134
*/
137135
public function redirect($url): void
138136
{
139-
$authorizationEndpoint = $this->getAuthorizationEndpoint();
140-
if (
141-
!empty($this->loginHint)
142-
&& str_starts_with($url, $authorizationEndpoint)
143-
) {
144-
$url .= "&" . http_build_query(['login_hint' => $this->loginHint]);
145-
}
146-
147137
throw new HttpResponseException(new RedirectResponse($url));
148138
}
149139

0 commit comments

Comments
 (0)