-
Notifications
You must be signed in to change notification settings - Fork 262
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
.signOut improvements #1439
.signOut improvements #1439
Conversation
@@ -101,7 +101,7 @@ export interface IsAuthenticatedOptions { | |||
} | |||
|
|||
export interface SignoutRedirectUrlOptions { | |||
postLogoutRedirectUri?: string; | |||
postLogoutRedirectUri?: string | null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is null needed here as it's already optional?
@@ -261,7 +261,7 @@ export function mixinOAuth | |||
if (!idToken) { | |||
return ''; | |||
} | |||
if (!postLogoutRedirectUri) { | |||
if (postLogoutRedirectUri === undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: add comment why undefined
is handled here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: not likely a real issue but I prefer to check typeof foo === 'undefined'
redirectUri.searchParams.append('state', state); | ||
} | ||
if (postLogoutRedirectUri === currentUri) { | ||
// window.location.reload(); // force a hard reload if URI is not changing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this commented code be removed?
(options.postLogoutRedirectUri | ||
|| this.options.postLogoutRedirectUri | ||
|| defaultUri; | ||
|| defaultUri); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Be careful -- options
vs this.options
. Is there a difference? Maybe a different variable name would help avoid confusion.
@@ -247,7 +247,7 @@ describe('OktaAuth (browser)', function() { | |||
expect(auth.revokeRefreshToken).toHaveBeenCalledWith(refreshToken); | |||
expect(auth.closeSession).not.toHaveBeenCalled(); | |||
expect(window.location.assign).toHaveBeenCalledWith(`${issuer}/oauth2/v1/logout?id_token_hint=${idToken.idToken}&post_logout_redirect_uri=${encodedOrigin}`); | |||
expect(signOutSuccess).toBeTruthy(); | |||
expect(signOutSuccess).toBe(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌
origin = 'https://somesite.local/'; | ||
href = `${origin}/some-route`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
idk if this matters but href
will have a double-/
with the change here
@@ -389,8 +396,8 @@ describe('OktaAuth (browser)', function() { | |||
expect(auth.tokenManager.getTokensSync).toHaveBeenCalledTimes(4); | |||
expect(auth.revokeAccessToken).toHaveBeenCalledWith(accessToken); | |||
expect(auth.closeSession).toHaveBeenCalled(); | |||
expect(window.location.reload).toHaveBeenCalled(); | |||
expect(signOutSuccess).toBeTruthy(); | |||
// expect(window.location.reload).toHaveBeenCalled(); // TODO: confirm href? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👀
Resolves #1410 and #1433
postLogoutRedirectUri
to benull
to invoke default/logout
redirect behaviorstate
as query param to redirect uri when.signOut
falls back to.closeSession