A forum with your store accounts (Discourse)
Your customers sign in to a Discourse forum with the same account they use in your store: no second password, and the forum knows who bought from you and…
Your customers sign in to a Discourse forum with the same account they use in your store: no second password, and the forum knows who bought from you and who sells in your market. This uses DiscourseConnect, Discourse's own single sign-on.
What happens
- Someone presses Log in on the forum.
- The forum sends them to your store, to
/cuenta/foro, with a signed request. - If they are not signed in to the store, they sign in or create an account there.
- The store answers the forum with their account, signed with a secret only the two of you know, and they land back on the forum already inside.
What the forum receives: the account id in the store (external_id, so changing the email does not create a second forum user), the email, the name and a username. If they have not confirmed their email in the store, the forum asks them to confirm it. Authors of your market are put in the authors group on every sign-in, and taken out if they stop being authors, so you can give them a badge, a colour or their own categories.
Set it up
1. Install Discourse. The official way is Docker on its own server or VPS: at least 1 GB of RAM with swap, 1 core and 10 GB of disk (2 GB and 2 cores are comfortable), on a 64-bit Linux, with its own subdomain such as forum.yourstore.com and an email service to send from. Follow the official cloud install guide: clone discourse_docker into /var/discourse and run ./discourse-setup.
2. Choose a secret. A long random text, at least 10 characters (better 32 or more). It is shared by the store and the forum and must not appear anywhere else.
3. Tell the store, in the backend environment:
PCC_FORO_URL=https://forum.yourstore.com
PCC_FORO_SECRETO=the-secret-you-chose
# PCC_FORO_GRUPO_AUTORES=authorsThe store only accepts going back to that address: a request asking to return anywhere else is refused, so the sign-in cannot be used to send people to another site.
4. Tell the forum. In Discourse, Admin → Settings → Login:
enable discourse connect: ondiscourse connect url:https://yourstore.com/cuenta/forodiscourse connect secret: the same secret- Create the
authorsgroup (or the one you named) if you want authors marked. - Optional:
auth overrides usernameandauth overrides namekeep usernames and names in step with the store;logout redirectsends people back to the store when they log out of the forum.
From then on, Log in on the forum goes through your store.
For theme authors
Themes reach this through the contract: commerce.forum.get() says whether the store has a forum (and its address, for a link in the menu), and commerce.forum.signIn(token, sso, sig) returns the address to send the person to. The base theme already has the /cuenta/foro page that does it.