Kyoso-Team / kyoso

A web application that takes osu! tournaments beyonds spreadsheets.
http://kyoso.sh
GNU Affero General Public License v3.0
1 stars 1 forks source link

(Dev environment) Add the ability for the dev to impersonate a user #27

Closed L-Mario564 closed 3 months ago

L-Mario564 commented 4 months ago

Why?

Impersonating a user is helpful to test stuff in a local environment, where the only real user is you. This will be especially helpful to test permissions, team invitation system, and other stuff that would require one or multiple users to perform an action. This would of course only be for development, not something that should be possible in testing or prod (for obvious reasons).

How?

My suggestion would be a simple menu that can be triggered in development through some key combination, where the dev then inputs the user ID of the user they want to impersonate. In the backend, an API route (that should error when not in development) can be used to re-sign the current session cookie with the data of the user to impersonate.

Pseudo-code:

> Dev has an ID of 100, wants to impersonate user with ID 20.
> Dev pulls up menu with key combination and inputs "20" somewhere and submits.
> The backend re-signs the current session cookie so the cookie has data of the user of ID 20, which means they can do anything as if they were user of ID 20.
> Reloads the current page.
Entropy-10 commented 4 months ago

Personally I have no issues with this, and can see that value that it adds so I'm all for adding this as a dev tool.

ArtemOsuskyi commented 4 months ago

Same here, can see a good merit in this being implemented

L-Mario564 commented 3 months ago

Implemented in recent commits I made. Read: https://github.com/Kyoso-Team/kyoso/blob/master/CONTRIBUTING.md#development-shortcuts.