# Discourse 在用户于私有站点登录后未重定向至 return\_sso\_url

**URL:** <https://meta.discourse.org/t/discourse-doesnt-redirect-to-return-sso-url-after-user-logs-in-on-private-site/97201>\
**Category:** Product Support\
**Created:** [2018 年9 月 14 日 17:40 UTC](https://meta.discourse.org/t/discourse-doesnt-redirect-to-return-sso-url-after-user-logs-in-on-private-site/97201 "2018-09-14T17:40:22Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

作者： ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)\
发布日期： [2018 年9 月 14 日 20:34 UTC](https://meta.discourse.org/t/discourse-doesnt-redirect-to-return-sso-url-after-user-logs-in-on-private-site/97201/2 "2018-09-14T20:34:47Z")

</div>

I’ve just tested this out with the [WP Discourse](https://github.com/discourse/wp-discourse) plugin and using Discourse as the SSO Provider is working correctly for me on a private site. Users who are already logged into Discourse are automatically redirected back to the website. Users who are not logged into Discourse are redirect to the Discourse `/login` page. After clicking the Login button and entering their credentials, they are redirected back to the website.

You can see the [WP Discourse](https://github.com/discourse/wp-discourse) implementation here: [wp-discourse/lib/sso-client at main · discourse/wp-discourse · GitHub](https://github.com/discourse/wp-discourse/tree/master/lib/sso-client). The important part is how the payload is created: [wp-discourse/lib/sso-client/query-redirect.php at main · discourse/wp-discourse · GitHub](https://github.com/discourse/wp-discourse/blob/master/lib/sso-client/query-redirect.php#L93).

In the Discourse code, the difference between how logged in and non-logged in users is handled starts here: [discourse/app/controllers/session\_controller.rb at main · discourse/discourse · GitHub](https://github.com/discourse/discourse/blob/master/app/controllers/session_controller.rb#L56). A non-logged in user is redirected to `/login` with `cookies[:sso_payload]` set to the query string you sent from your django app. After being logged in, the `sso_provider` code should be being called again, with the payload set to the value of `cookies[:sso_payload]`. It seems that’s not happening for you.

---

_[View the full topic](https://meta.discourse.org/t/discourse-doesnt-redirect-to-return-sso-url-after-user-logs-in-on-private-site/97201)._
