Revoke session
# bot-training
r
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:
Copy code
Session.init({
    override: {
        functions: (originalImplementation) => {
            return {
                ...originalImplementation,
                createNewSession: async function (input) {
                    let existingSessions = await Session.getAllSessionHandlesForUser(input.userId);
                    existingSessions.forEach(async (session) => {
                        await Session.revokeSession(session);
                    })
                    return originalImplementation.createNewSession(input);
                }
            }
        }
    }
})
st-bot-test-case