按ID获取用户个人资料页面?

是否可以通过用户ID访问公开用户资料的路线?

我知道:https://meta.discourse.org/u/{username}/summary
我想要:https://meta.discourse.org/u/{user-id}/summary

目的:我希望我的主网站上的个人资料能链接到 Discourse 网站上的个人资料。问题在于,最初我没有使用 SSO,因此两个网站之间的用户名并不完全一致,并且会在用户登出/登录时更新。我尝试“清除”旧的用户ID,却发现没有用于更新用户名的端点(只能更新电子邮件和头像)。

由于用户名正在发生变化,我改存储了id,但现在我意识到无法直接生成通过ID访问其资料的URL。我将不得不进行额外的网络请求,而我正试图避免这种情况。否则,我认为我必须调用一次by-external端点来获取用户名,但如果有重定向功能就更好了。

If you’re trying let users get their own profile, yo can use /my/summary/

https://meta.discourse.org/my/summary

Thanks but no, I want any user viewing a profile on my main site, to be able to click a link on that page to take them to the corresponding profile on the discourse page.

It would be great if there were a PUT endpoint for username. The use case is sites like mine which transitioned to SSO, to get all the usernames synced. Then my plan A would have just worked.

My fallback plan I think is going to be to add another column to store discourse_username also in my DB along with discourse_id. This way, I can directly to their profile with username. The downside is that this username can change. So I need to daily scan all users to re-sync.

You can make a POST request to /admin/users/sync_sso for this. If you are using the Discourse API gem, you can use the gem’s sync_sso method for this. If you are not using the gem, see Sync DiscourseConnect user data with the sync_sso route for details about setting up the request.