Revoke session


04/04/2023, 11:26 AM
Do you support the feature that when a user logs in from another computer, all his previous tokens and sessions are deleted, so that multiple users cannot use the account at the same time?
Yes, we do. You can achieve this by overriding the createNewSession function (which is calling during sign in or sign up) and revoking other sessions belonging to the user based on the session recipe's functions. For example, in node, you can do:
    override: {
        functions: (originalImplementation) => {
            return {
                createNewSession: async function (input) {
                    let existingSessions = await Session.getAllSessionHandlesForUser(input.userId);
                    existingSessions.forEach(async (session) => {
                        await Session.revokeSession(session);
                    return originalImplementation.createNewSession(input);