Account sharing

See when one login runs on too many devices.

10 minutes

When one login is used on many devices, it is usually a shared subscription, a sold account or a credential-stuffing success. Trace counts the distinct devices behind each account so you can ask for a re-login, limit sessions or flag the account.

What you will build: a login check that notices when an account is used on more devices than you allow.

  1. 1

    Identify with the account id

    Pass your user id as linkedId every time a signed-in user is identified: at login, and optionally on app start.

    TypeScript
    const { eventId } = await trace.get({ linkedId: user.id, tags: { action: 'login' } });

    Use an internal id, not an email. Trace only counts accounts it has seen through linkedId.

  2. 2

    Read the device count

    TypeScript
    const event = await verifyEvent(eventId, { secretKey, endpoint, timeoutMs: 1500 }).catch(() => null);
    const sharing = event?.signals.accountSharing;
    
    if (sharing?.detected) {
      // devicesForAccount is above accounts.maxDevicesPerAccount (5 by default) within 30 days
      console.info('account on many devices', user.id, sharing.details.devicesForAccount);
    }

    Devices are counted by deviceId, so Chrome and Firefox on one laptop are one device, not two.

  3. 3

    Choose a response

    Your productTypical response
    Streaming or SaaS seatsShow "signed in on too many devices" and end the oldest session
    Marketplace or fintechRequire a one-time code on new devices
    Anything after a breachForce a password reset when accountSharing and velocity fire together

    Raise or lower the limit with accounts.maxDevicesPerAccount in the scoring file.

    Families share

    A household with phones, tablets and a laptop can pass five devices. Measure your own distribution before enforcing.

Next steps

Suggest an edit

Spotted something wrong or unclear? Tell us on GitHub and we will fix it.