Auto Login enabled for public facing community?

You’re absolutely right that clicking ‘reply’ will trigger the login flow. And if DiscourseConnect (or any other single login provider) is being used, then the Discourse login modal will be skipped :+1:

However, I think the OP wants to have people automatically logged in, without them needing to click reply or ‘login’. With that kind of setup, it would be totally seamless for users to move between the main site and the community. We’ve achieved this for a couple of customers, but these have been bespoke implementations which can’t be easily generalised.

To give an example of one approach: if your forum is on forum.example.com, and your main site is on example.com, then the forum is allowed to read cookies from example.com. So a theme component can check for the existence of a cookie and do something like this:

const cookie = require("discourse/lib/cookie").default;
if(cookie('name_of_example_com_auth_cookie') && !api.getCurrentUser()){
  // User has an auth cookie for example.com. They are almost certainly
  // logged in there, so let's run the auth flow
  window.location = "https://forum.example.com/auth/oidc"
}

(various conditions apply here. e.g. the cookie must not be http_only, must not be a host-only cookie, etc.)

4 Likes