Do tokens overwrite each other on the same User document? (Auth)

Hey all! I have a login flow that creates an auth token (ttl: 5 minutes) for a user document stored in a User collection.

If I execute the flow sequentially (or from two separate machines), does it create two valid tokens on the User document? Or, does the first token get overwritten?

Multiple tokens can exist for a particular identity. This feature could be used to provide identity-based access on multiple devices at once.

I noticed this in the tokens documentation, does this mean that by default, creating another token on a document doesn’t overwrite previously written tokens?

Thank you for the clarification :slight_smile:

does it create two valid tokens on the User document? Or, does the first token get overwritten?

Each Login call creates a new token. Similarly, when you create token documents directly, no existing tokens are removed.

You can create an index on the Tokens collection with the instance field defined as a term. That would let you search for all existing tokens associated with an identity document. You could use those search results to apply a token management policy.

does this mean that by default, creating another token on a document doesn’t overwrite previously written tokens?

Yes.

1 Like

Thank you, appreciate the clarification.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.