Skip to content

Commit 453d62c

Browse files
Tamas-hiHargitai Tamas
andauthored
Add support for optional post_logout_redirect_uri (#1174)
Co-authored-by: Hargitai Tamas <[email protected]>
1 parent 286adfc commit 453d62c

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

Provider.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,20 @@ protected function getAuthUrl($state)
3737
}
3838

3939
/**
40-
* Return the logout endpoint with post_logout_redirect_uri query parameter.
40+
* Return the logout endpoint with an optional post_logout_redirect_uri query parameter.
4141
*
42-
* @param string $redirectUri
43-
* @return string
42+
* @param string|null $redirectUri The URI to redirect to after logout, if provided.
43+
* If not provided, no post_logout_redirect_uri parameter will be included.
44+
*
45+
* @return string The logout endpoint URL.
4446
*/
45-
public function getLogoutUrl(string $redirectUri)
47+
public function getLogoutUrl(?string $redirectUri = null)
4648
{
47-
return $this->getBaseUrl()
48-
.'/oauth2/logout?'
49-
.http_build_query(['post_logout_redirect_uri' => $redirectUri], '', '&', $this->encodingType);
49+
$logoutUrl = $this->getBaseUrl().'/oauth2/logout';
50+
51+
return $redirectUri === null ?
52+
$logoutUrl :
53+
$logoutUrl.'?'.http_build_query(['post_logout_redirect_uri' => $redirectUri], '', '&', $this->encodingType);
5054
}
5155

5256
/**

0 commit comments

Comments
 (0)