-
Notifications
You must be signed in to change notification settings - Fork 168
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
[full-ci] Fix unloading user with oc10 backend #7128
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,38 +24,26 @@ const state = { | |
} | ||
|
||
const actions = { | ||
cleanUpLoginState(context, options = { clearOIDCLoginState: true }) { | ||
cleanUpLoginState(context) { | ||
if (context.state.id === '') { | ||
return | ||
} | ||
|
||
// reset user | ||
this.reset({ self: false, nested: false, modules: { user: { self: true } } }) | ||
|
||
// clear dynamic navItems | ||
context.dispatch('clearDynamicNavItems') | ||
|
||
if (options.clearOIDCLoginState) { | ||
// clear oidc client state | ||
vueAuthInstance.clearLoginState() | ||
} | ||
// clear oidc client state | ||
vueAuthInstance.clearLoginState() | ||
}, | ||
async logout(context) { | ||
const logoutFinalizer = (isOauth2 = false) => { | ||
const logoutFinalizer = () => { | ||
// Remove signed in user | ||
context.dispatch('cleanUpLoginState', { clearOIDCLoginState: !isOauth2 }) | ||
context.dispatch('cleanUpLoginState') | ||
context.dispatch('hideModal') | ||
context.dispatch('loadSettingsValues') | ||
|
||
// Force redirect | ||
if (isOauth2) { | ||
if (context.getters?.configuration?.auth?.logoutUrl) { | ||
return (window.location = context.getters?.configuration?.auth?.logoutUrl) | ||
} else if (context.getters?.configuration?.server) { | ||
return (window.location = `${context.getters?.configuration?.server}/index.php/logout`) | ||
} | ||
|
||
router.push({ name: 'login' }) | ||
} | ||
} | ||
const u = await vueAuthInstance.getStoredUserObject() | ||
|
||
|
@@ -73,7 +61,7 @@ const actions = { | |
}) | ||
} else { | ||
// Oauth2 logout | ||
logoutFinalizer(true) | ||
logoutFinalizer() | ||
} | ||
}, | ||
async initAuth(context, payload = { autoRedirect: false }) { | ||
|
@@ -172,6 +160,15 @@ const actions = { | |
vueAuthInstance.events().addUserUnloaded(() => { | ||
console.log('user unloaded…') | ||
context.dispatch('cleanUpLoginState') | ||
|
||
if (context.getters?.configuration?.auth) { | ||
// => OAuth2 | ||
if (context.getters?.configuration?.auth?.logoutUrl) { | ||
return (window.location = context.getters?.configuration?.auth?.logoutUrl) | ||
} else if (context.getters?.configuration?.server) { | ||
return (window.location = `${context.getters?.configuration?.server}index.php/logout`) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also made sure that there is no double |
||
} | ||
} | ||
router.push({ name: 'login' }) | ||
}) | ||
vueAuthInstance.events().addSilentRenewError((error) => { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@dschmidt for more clarity: this function removes the user from the oidc user manager (boils down to being removed from the session storage). So it must be used unconditionally on logout (before it was only used for OIDC but not for OAuth2). The only issue was that the user unload event itself had a redirect to the login page, which was then faster than the intended redirect to the oc10 logout url which is called further down in the
logout
function. I moved the code that determines the logout url to the user unload event and removed it from the logout function. That's the gist of this PR.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.
Sounds right!