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

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