Revoke impersonate session after stopping to impersonate #1008

Closed
opened 2026-03-13 08:17:15 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @MarcMogdanz on GitHub (Apr 8, 2025).

Is this suited for github?

  • Yes, this is suited for github

I've noticed that when you stop impersonating a user, it will not revoke the session that was created but rather just change out the impersonate session to your original admin user session.

Describe the solution you'd like

Ideally when calling the authClient.admin.stopImpersonating() function it should be possible to revoke the session totally. Since there's no way in the SDK to reuse the created impersonate session, there's no reason for it to exist anymore when the admin stopped impersonating. Starting to impersonate the same user will still trigger a new impersonate session to be created.

Describe alternatives you've considered

Currently I'm manually revoking the session when stopping to impersonate which works, but imo this should be part of the stopImpersonating() function itself

Additional context

No response

Originally created by @MarcMogdanz on GitHub (Apr 8, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### Is your feature request related to a problem? Please describe. I've noticed that when you stop impersonating a user, it will not revoke the session that was created but rather just change out the impersonate session to your original admin user session. ### Describe the solution you'd like Ideally when calling the `authClient.admin.stopImpersonating()` function it should be possible to revoke the session totally. Since there's no way in the SDK to reuse the created impersonate session, there's no reason for it to exist anymore when the admin stopped impersonating. Starting to impersonate the same user will still trigger a new impersonate session to be created. ### Describe alternatives you've considered Currently I'm manually revoking the session when stopping to impersonate which works, but imo this should be part of the `stopImpersonating()` function itself ### Additional context _No response_
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#1008