Skip to content

Login

To comment, the person has to be logged in. There are two ways, and you can turn on one or both in the dashboard's Settings tab.

Your site's loginQorum account
For whomSites that already have users and a loginSites without a login, or people without an account on your site
What the person doesNothing: they're already in with your site's accountCreates a username and password inside the widget
What you doA route on your server that creates a tokenNothing: just leave the option on
Name and photoCome from your site, the way you send themThe Qorum account's username and display name

With both on, the widget uses your site's login when it exists and offers a Qorum account to whoever isn't logged in.

Your site's login

The idea: your server, which already knows who is logged in, creates a token saying "this is Ana, id 123". The token is signed with your secret key, so Qorum knows you created it and nobody tampered with it.

  1. The page asks your server for a token

    Through a route of yours, like /qorum-token, only for logged-in people.

  2. Your server signs it and sends it back

    With the secret key, which never leaves the server.

  3. The page hands the token to the widget

    In the token option. The widget sends the token to Qorum on every request.

  4. Qorum checks the signature

    If everything is right, the person comments with the name and photo you sent.

What goes inside the token

It's a JWT signed with HS256 and the site's secret key. There are JWT libraries for every language.

FieldRequiredWhat to put
subyesThe user's id on your site, as text. Up to 64 characters: letters, numbers and _ . : @ -. This id must never change for the same person.
audyesThe site's public key (pk_...). Yes, the public one: it says which site the token is for.
iatyesWhen the token was created, in seconds since 1970. Most libraries fill it in for you.
expyesWhen the token expires. At most 25 hours after iat. Recommended: 12 hours.
nameyesThe name shown on comments (up to 120 characters).
cardnoAn object with the person's look. See The card.
modnotrue for people on your team: they can approve, delete, pin and ban from the widget.

1. The route on your server

It returns {"token": "..."} for logged-in people and 401 for everyone else. Keep the secret key in an environment variable, never in code that goes to the browser.

// npm install jsonwebtoken
const jwt = require('jsonwebtoken');

app.get('/qorum-token', (req, res) => {
  const user = req.user;                 // the user logged in to your site
  if (!user) return res.sendStatus(401);
  const token = jwt.sign(
    {
      name: user.name,
      card: { username: user.username, avatar: user.photoUrl },
      mod: user.isAdmin === true,
    },
    process.env.QORUM_SECRET,             // sk_...
    {
      algorithm: 'HS256',
      subject: String(user.id),
      audience: 'pk_YOUR_PUBLIC_KEY',
      expiresIn: '12h',
    }
  );
  res.json({ token });
});

2. The page code

The page fetches the token and hands it to the widget. When it expires, the widget says so through onExpired and the page fetches another:

<div id="comentarios"></div>
<script src="https://useqorum.com/widget.js"></script>
<script>
  let token = null;

  async function fetchToken() {
    const r = await fetch('/qorum-token', { credentials: 'same-origin' });
    token = r.ok ? (await r.json()).token : null;   // 401 = nobody logged in
    return token;
  }

  fetchToken().then(() => {
    const comments = Qorum.montar(document.getElementById('comentarios'), {
      key: 'pk_YOUR_PUBLIC_KEY',
      ref: 'post-42',
      token: () => token,
      onLogin: () => { location.href = '/login?back=' + encodeURIComponent(location.href); },
      onExpired: async () => { comments.definirToken(await fetchToken()); }
    });
  });
</script>

The card

The card is free-form: Qorum stores it and returns it the way you sent it, in the user field of each comment. If you use the API you can put whatever your design needs there. The ready-made widget understands these fields:

FieldWhat the widget shows
usernameUsed when there's no displayName.
displayNameThe highlighted name on the comment.
avatarThe https address of the photo. With no photo, the name's initial shows up.
rankA badge with a name, color and optional icon: {"name": "Subscriber", "nameColor": "#7c3aed", "icon": "https://..."}. The color also paints the name.
isStaffShows the "Staff" badge.
isVipShows a highlight badge.
avatarFrame, avatarFrameScaleA decorative image over the photo and its size relative to the photo (default 1.2).

Would you rather Qorum fetch the card from your site? See Site data. Without it, the card is updated whenever the person uses a new token. To update it right away (the person changed their photo, for example), use PUT /v1/site/users/:id/card in the management API.

Security

Checking the token

In the dashboard's Test connection tab, paste a token created by your server. The test says exactly what is wrong, like "aud must be this site's public key" or "token expired", and shows the content Qorum read. The management API runs the same test.

Qorum account

With the option on, the widget shows the Log in button to whoever isn't logged in. The person chooses between logging in and signing up:

There's no e-mail and no password recovery. The account works on every site that uses Qorum, but the person logs in separately on each site. The login lasts 30 days. On comments, this person's id shows up as q: followed by a number, like q:12.

People you add as moderators in the dashboard become moderators in the widget when they log in with their Qorum account.

Building your own interface? The log in and sign up routes are in the public API.