A workaround that seems to work (code to be put in a plugin initializer):
// In case this is a SSO login...
if (window.location.pathname === '/login') {
// Put a hook on the closeModal function, so that we redirect user
// to the original web site if he closes the login or create-account modal
ApplicationRoute.reopen({
actions: {
closeModal() {
if ($('.modal.login-modal, .modal.create-account').length) {
location.href = document.referrer
} else {
this._super()
}
}
}
})
}
EDIT: Iāve edited my first post, sorry for the confusion. Iām using Discourse as an identity provider.
Consider a user reading a page on a web site. The web site uses Discourse both for its āforumā section and as an identity provider. In order to perform an action (outside of the forum), the user needs to login. Then:
Scenario 1: user enters his credential, login succeeds, user comes back to where he was and can continue.
Scenario 2: user changes his mind and decides he doesnāt want to log in. If he uses the ābackā button, he comes back to where he was and can continue. If he uses the X button to close the modal or hit the ESC key, he lands in the discussion forum. I think he should go back to where he was instead.
We also really want to use discourse as login provider from our main site, but canceling the login/account creation and just ending up on the forums isnāt really a good option. As people might not know about the forum at all yet.
We just need to call the login box on its own and be able to return safely to where we call it from.
So maybe a more stylable option rich login box/account creation for SSO is needed? So it can be used in a popup or standalone.
This way we will have the security and safety of good account creations of discourse and natural SSO integration.
Yes indeed - when login box is closed user should just be redirected back.
But as it is the same login box for regular login and SSO login - how can you distinguish the styling?
Or is there a special css class applied when called as SSO login?
Same as above ā¦ how can we style and customize the SSO login only? but not the regular