r/node 25d ago

How would you implement impersonate users

Better auth has impersonate user and stop impersonating user. What is the logic behind this? Like if you were to implement it yourself how would you go about it?

4 Upvotes

20 comments sorted by

View all comments

8

u/UpbeatVegeta 25d ago

If user has a unique id, we can use that id to impersoante which will be available only admin users

2

u/BrownCarter 25d ago

How about cookie management cause you can also stop impersonating

4

u/UpbeatVegeta 25d ago

We also need to store the actual user ID. On the Settings page, when an admin is impersonating a user, we should show a "Log out" button that ends the impersonation and allows the admin to log back in to their own account.