Skip to content

Is it possible to sign out all other user sessions except the current one? #5243

Discussion options

You must be logged in to vote

Well, logout kills all "sessions" currently. That function mainly logs a message and deletes all refresh tokens from auth.refresh_tokens table for the uid.

From gotrue:

// Logout deletes all refresh tokens for a user.
func Logout(tx *storage.Connection, instanceID uuid.UUID, id uuid.UUID) error {
	return tx.RawQuery("DELETE FROM "+(&pop.Model{Value: RefreshToken{}}).TableName()+" WHERE instance_id = ? AND user_id = ?", instanceID, id).Exec()
}

You might be able to trigger on before insert to that table (new refresh token created on login) and in that trigger delete all refresh_tokens for that uid. You probably need to do some checking on when else inserts occur to table, if any.

With the…

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by J0
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@GaryAustin1
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auth All thing Supabase Auth related
4 participants