Skip to content

Commit

Permalink
manfredsteyer#739: Add optional state parameter for logout
Browse files Browse the repository at this point in the history
  • Loading branch information
pmccloghrylaing committed Mar 11, 2020
1 parent 41a6ea0 commit 37129f4
Showing 1 changed file with 7 additions and 2 deletions.
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

0 comments on commit 37129f4

Please sign in to comment.