# Private message composition URLs don't work with SSO

**URL:** https://meta.discourse.org/t/private-message-composition-urls-dont-work-with-sso/41419
**Category:** Bug
**Created:** [2016 年 3 月 22 日午後 1:43 UTC](https://meta.discourse.org/t/private-message-composition-urls-dont-work-with-sso/41419 "2016-03-22T13:43:08Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![toolness](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/toolness/32/114496_2.png) [@toolness](https://meta.discourse.org/u/toolness)
#### Post date: [2016 年 3 月 22 日午後 1:43 UTC](https://meta.discourse.org/t/private-message-composition-urls-dont-work-with-sso/41419/1 "2016-03-22T13:43:08Z")

</div>

Hello! Discourse is awesome but I seem to be encountering an odd bug related to [Discourse SSO](https://meta.discourse.org/t/13045?silent=true) and the [Compose a new pre-filled private message via URL](https://meta.discourse.org/t/compose-a-new-pre-filled-private-message-via-url/35984) functionality.

Here’s what’s going on.

1. A user is logged into my SSO site at `https://example.org`. They have not yet visited my Discourse site at `https://discourse.example.org`, so they don’t have a session established there yet.
2. While on my SSO site, the user clicks on a link that takes them to `https://discourse.example.org/new-message?username=foo`. (Assume that `foo` is a valid user on my Discourse install.)
3. My Discourse site notices that the user isn’t logged-in and redirects them to my SSO site, which immediately sends them back to my Discourse site.
4. For a fraction of a second, the URL in the user’s address bar appears to be `https://discourse.example.org/new-message`, but it then changes to `https://discourse.example.org/`.
5. A modal with the text “Sorry, an error has occurred” appears on the Discourse site.

This bug _only_ seems to occur when the user clicks on a private message composition link and isn’t yet logged in to Discourse. Everything works fine if the user already has a Discourse session.

Everything also works fine if the user isn’t yet logged into Discourse and clicks a non-PM-composition link. For example, if the user clicks on a link to a specific topic, Discourse navigates to that topic after the SSO handshake without any problems. It’s _only_ with PM composition links that Discourse appears to “forget” that it was supposed to open a PM composition link to `foo` after the SSO handshake.

Does this make sense? Is anyone else experiencing the same problem? If this is actually a bug, I’m willing to investigate the issue and submit a PR to fix it.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [2016 年 3 月 22 日午後 9:09 UTC](https://meta.discourse.org/t/private-message-composition-urls-dont-work-with-sso/41419/2 "2016-03-22T21:09:58Z")

</div>

Sure, if you’d like to submit a PR that’d be great!

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2017 年 6 月 2 日午後 5:59 UTC](https://meta.discourse.org/t/private-message-composition-urls-dont-work-with-sso/41419/3 "2017-06-02T17:59:27Z")

</div>

Seems to be working fine now. Closing.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2017 年 6 月 2 日午後 5:59 UTC](https://meta.discourse.org/t/private-message-composition-urls-dont-work-with-sso/41419/4 "2017-06-02T17:59:29Z")

</div>


