# 检查其他网站上用户是否已登录 Discourse

**URL:** <https://meta.discourse.org/t/checking-whether-a-user-is-logged-in-on-discourse-from-another-website/291185>\
**Category:** SSO\
**Created:** [2024年一月10日 15:21 UTC](https://meta.discourse.org/t/checking-whether-a-user-is-logged-in-on-discourse-from-another-website/291185 "2024-01-10T15:21:30Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)\
**Post date:** [2024年七月3日 18:46 UTC](https://meta.discourse.org/t/checking-whether-a-user-is-logged-in-on-discourse-from-another-website/291185/3 "2024-07-03T18:46:18Z")

</div>

> [@alehandrof](#):
>
> 我想根据某人是否在我们私有的 Discourse 上拥有会员账户来限制对我们网站上某些页面的访问。

您可以使用 [DiscourseConnect](https://meta.discourse.org/t/13045?silent=true) 来实现此目的（以 Discourse 作为身份验证提供者）：[https://meta.discourse.org/t/use-discourse-as-an-identity-provider-sso-discourseconnect/32974。](https://meta.discourse.org/t/use-discourse-as-an-identity-provider-sso-discourseconnect/32974%E3%80%82)

我还没有尝试过，但 `prompt` 参数可能对您的情况有用：

> - `prompt`: 如果 `prompt=none`，则 SSO 请求被视为“仅检查”请求。如果浏览器/设备已登录 Discourse，Discourse 将像往常一样返回成功的 SSO 响应，其中包含用户信息。如果浏览器/设备_未_登录，则 Discourse 不会要求用户登录，而是会立即返回一个带有 `failed=true` 参数的 SSO 响应，而不是用户信息。这提供了一种查询用户是否已登录的机制，而无需在用户未登录时将其重定向到登录对话框。

---

_[View the full topic](https://meta.discourse.org/t/checking-whether-a-user-is-logged-in-on-discourse-from-another-website/291185)._
