The discussion revolves around forcing a login or signup popup to appear on page load via a URL query string in Discourse. vinothkannans asks if it’s possible to trigger the login popup when a user lands on a page with a specific query string, such as ?login=true. riking clarifies that currently, only /login and /signup URLs automatically trigger the popup. stevenpslade suggests a workaround using JavaScript to detect the query string and display a modal, potentially via the application route or api.onPageChange(). vinothkannans appreciates the suggestions and plans to test them. ngm shares a related use case involving SSO authentication, where a login query parameter could be used to automatically authenticate users and redirect them to private content, highlighting the need for a more seamless login flow.
I know it may be an unusual request. But am I like to find a way to do it. Is there any way to just display login or signup popup on page load when a user landed on that page with some special query string?
For example https://meta.discourse.org/t/any-way-to-force-login-popup-to-open-by-url-query-string/46193?login=true
When the URL’s query string looks like above I want to open login popup on that page itself
It isn’t exactly what you are trying to do, but I’ll share what work I’ve recently done with modals on our Discourse.
We wanted a modal to appear after a user took a particular action (clicking a button). I put the modal handlebars/html in a plugin outlet and using CSS set it to display none. Then, when the user takes the desired action, I set the modal to display: block.
Here are some thoughts I have for your situation that I’d be happy to brainstorm with you:
• Using JS, could you check the url for a particular query and, if the query string existed, display the modal? This would work on the initial load but you might also be able to utilize api.onPageChange() to check the url as Ember is doing it’s magic.
• The aforementioned JS could potentially be placed in the application route?
I’ve got a similar question. Although not to display the login popup, but to log the user in via our SSO provider if there is a login query string parameter.
We use our own system as the SSO provider to Discourse.
We have a mixture of public and private pages on our Discourse, so we don’t have login_required set.
If a user authenticates in to our system, and we link them to our Discourse root url, they are shown the public categories but are not logged in.
If a user authenticates in to our system, and we link them to our Discourse + /login, they are logged in fine, and redirected to the root Discourse URL.
If a user authenticates in to our system, and we link them to the URL of a private category/topic in Discourse, they are shown a page asking them to login. If they click Login, they are automatically logged in and shown the category/topic.
This last case is the problematic one. I think one of the following would be good:
we can link to ourdiscourse dot com/c/some-category?login=true and an auth check is performed - if user is logged in, show them the topic. If not, send them to our SSO provider, and redirect them back to the topic after logging in.
we can link to ourdiscourse dot com/login?redirect=c/some-category and an auth check is performed - if successful, redirect to the page on the query string, if not, redirect to SSO provider, and redirect to the page on the query string after successful authentication
we can link to ourdiscourse dot com/c/some-category, and if it’s a private page, Discourse performs an auth check, which if successful takes you to the category; if not successful, redirects to SSO provider, then redirects back.