Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: ClanID auth guard #353

Open
PlayJeri opened this issue Dec 15, 2024 · 0 comments
Open

Feature request: ClanID auth guard #353

PlayJeri opened this issue Dec 15, 2024 · 0 comments
Assignees
Labels
feature New feature to add

Comments

@PlayJeri
Copy link
Collaborator

What do you want to see in the API?

There are a lot of endpoints in this API that need the clan_id of the user that made the request. Current way has been to inject the player service to the service that handles the incoming request and then query the db with the player_id provided in the request context and LoggedUser decorator. This adds a lot of repeated code and makes it necessary to inject player service to several other services that might only need it for the clan_id.

My suggestion would be that the AuthGuard would attach the clan_id to the request context if a @GetClanID() decorator is added to the controller or a specific endpoint. In my opinion this would simplify the process of getting the clan id and it would always be handled in the same place.

How do you think this should work?

  1. Add GetClanId decorator that sets metadata SetMetadata(GET_CLAN_ID, true)
  2. Inject Player service to the auth guard.
  3. Add to AuthGuard reflector.getAllAndOverride(GET_CLAN_ID) and if its found then call the playerService with user.player_id from jwt token and attach the found clan_id to the request context
  4. Add optional clan_id to the User class

Any additional info?

This should be easy replacement for the existing services that call the playerService for clan_id when refactoring the services and easier option to implemet into new services and endpoints.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature to add
Projects
Status: Backlog
Development

No branches or pull requests

2 participants