# Login redirect during sso provider login

**URL:** <https://meta.discourse.org/t/login-redirect-during-sso-provider-login/29759>\
**Category:** Bug\
**Tags:** sso, discourseconnect\
**Created:** [June 8, 2015, 6:23am UTC](https://meta.discourse.org/t/login-redirect-during-sso-provider-login/29759 "2015-06-08T06:23:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![paxmanchris](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/paxmanchris/32/116126_2.png) [@paxmanchris](https://meta.discourse.org/u/paxmanchris)\
**Post date:** [June 8, 2015, 6:23am UTC](https://meta.discourse.org/t/login-redirect-during-sso-provider-login/29759/1 "2015-06-08T06:23:13Z")

</div>

On my site, lets say `example.com`, I have a link to my discourse site with a sso payload. For example `discourse.com/session/sso_provider?sso=afjakfj&sig=sdjfsdkfj`. After the user clicks this link, **If the user is not logged on to Discourse** , the user is first redirected to the `discourse.com/login`. When the user successfully enters their username and password, there is an ajax request in the background to the `return_sso_url` stored in the payload; **the page then proceeds to redirect the user to the index** of `discourse.com`. I expect the user to be redirected back to `example.com`.

For background see [Using the Discourse SSO provider feature](https://meta.discourse.org/t/using-the-discourse-sso-provider-feature/29272/4).

---

<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:** [June 8, 2015, 6:33am UTC](https://meta.discourse.org/t/login-redirect-during-sso-provider-login/29759/2 "2015-06-08T06:33:08Z")

</div>

@techAPJ can you give fixing this a shot, its a bit tricky but testable in an integration test

---

<div class="post-metadata">

**Author:** ![fbender](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fbender/32/116736_2.png) [@fbender](https://meta.discourse.org/u/fbender)\
**Post date:** [September 21, 2015, 9:30pm UTC](https://meta.discourse.org/t/login-redirect-during-sso-provider-login/29759/3 "2015-09-21T21:30:30Z")

</div>

Any progress here? @techAPJ

---

<div class="post-metadata">

**Author:** ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)\
**Post date:** [October 25, 2015, 6:11am UTC](https://meta.discourse.org/t/login-redirect-during-sso-provider-login/29759/4 "2015-10-25T06:11:02Z")

</div>

Okay, fixed this bug (finally!) 🐢

[https://github.com/discourse/discourse/commit/c28843e87bb8d4fc94124a4d530acc988d60e579](https://github.com/discourse/discourse/commit/c28843e87bb8d4fc94124a4d530acc988d60e579)

Verified the code by testing against [PHP scripts](https://gist.github.com/paxmanchris/e93018a3e8fbdfced039) created by @paxmanchris (thanks!) 🎁

---

<div class="post-metadata">

**Author:** ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)\
**Post date:** [October 25, 2015, 7:48pm UTC](https://meta.discourse.org/t/login-redirect-during-sso-provider-login/29759/5 "2015-10-25T19:48:01Z")

</div>


