Skip to content

Add optional state parameter for logout #744

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 21, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions projects/lib/src/oauth-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2095,10 +2095,11 @@ export class OAuthService extends AuthConfig implements OnDestroy {
/**
* Removes all tokens and logs the user out.
* If a logout url is configured, the user is
* redirected to it.
* redirected to it with optional state parameter.
* @param noRedirectToLogoutUrl
* @param state
*/
public logOut(noRedirectToLogoutUrl = false): void {
public logOut(noRedirectToLogoutUrl = false, state = ''): void {
const id_token = this.getIdToken();
this._storage.removeItem('access_token');
this._storage.removeItem('id_token');
Expand Down Expand Up @@ -2151,6 +2152,10 @@ export class OAuthService extends AuthConfig implements OnDestroy {
const postLogoutUrl = this.postLogoutRedirectUri || this.redirectUri;
if (postLogoutUrl) {
params = params.set('post_logout_redirect_uri', postLogoutUrl);

if (state) {
params = params.set('state', state);
}
}

logoutUrl =
Expand Down