Skip to content
This repository has been archived by the owner on Nov 4, 2020. It is now read-only.

Latest commit

 

History

History
31 lines (24 loc) · 773 Bytes

log-out-a-users-magic-session.md

File metadata and controls

31 lines (24 loc) · 773 Bytes

Log Out a User's Magic Session

Sometimes you will find yourself needing to log your users out from the server-side. This provides a small example of how to do so.

Prerequisite

Step 1: Invalidate the user session

{% tabs %} {% tab title="With public address" %}

app.post('/logout', (req: any, res: any) => {
  const userPublicAddress = magicAdmin.token.getPublicAddress(
    req.headers.authorization
  );
  magicAdmin.users.logoutByPublicAddress(userPublicAddress);
});

{% endtab %}

{% tab title="With DID Token" %}

app.post('/logout', (req: any, res: any) => {
  magicAdmin.token.invalidate(req.headers.authorization);
});

{% endtab %} {% endtabs %}