# Any way to force login popup to open by url query string?

**URL:** https://meta.discourse.org/t/any-way-to-force-login-popup-to-open-by-url-query-string/46193
**Category:** Feature
**Created:** [22 juni 2016 om 15:43 UTC](https://meta.discourse.org/t/any-way-to-force-login-popup-to-open-by-url-query-string/46193 "2016-06-22T15:43:36Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [22 juni 2016 om 15:43 UTC](https://meta.discourse.org/t/any-way-to-force-login-popup-to-open-by-url-query-string/46193/1 "2016-06-22T15:43:36Z")

</div>

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**

---

<div class="post-metadata">

### Author: ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)
#### Post date: [26 juni 2016 om 18:06 UTC](https://meta.discourse.org/t/any-way-to-force-login-popup-to-open-by-url-query-string/46193/2 "2016-06-26T18:06:19Z")

</div>

Not currently; the only URLs that automatically pop up the login box are `/login` and `/signup`.

---

<div class="post-metadata">

### Author: ![stevenpslade](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stevenpslade/32/53550_2.png) [@stevenpslade](https://meta.discourse.org/u/stevenpslade)
#### Post date: [27 juni 2016 om 23:43 UTC](https://meta.discourse.org/t/any-way-to-force-login-popup-to-open-by-url-query-string/46193/3 "2016-06-27T23:43:37Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![vinothkannans](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/vinothkannans/32/86465_2.png) [@vinothkannans](https://meta.discourse.org/u/vinothkannans)
#### Post date: [28 juni 2016 om 09:29 UTC](https://meta.discourse.org/t/any-way-to-force-login-popup-to-open-by-url-query-string/46193/4 "2016-06-28T09:29:31Z")

</div>

Thanks for your responses @riking @stevenpslade

> [@stevenpslade](#):
>
> • 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 will check these methods on mine and let you know. Thanks again 🙂

---

<div class="post-metadata">

### Author: ![ngm](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ngm/32/113693_2.png) [@ngm](https://meta.discourse.org/u/ngm)
#### Post date: [8 oktober 2018 om 17:32 UTC](https://meta.discourse.org/t/any-way-to-force-login-popup-to-open-by-url-query-string/46193/5 "2018-10-08T17:32:50Z")

</div>

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.

Thanks!
