octoposprime / op-be-graphql

OctopOS Prime Backend Api Gateway
http://www.octoposprime.com
MIT License
13 stars 1 forks source link

Cleanup User Auth Code in GraphQL Resolvers #88

Open Feyzanrs opened 2 months ago

Feyzanrs commented 2 months ago

In the pkg\presentation\controller\graphql\resolver\dlr.resolvers.go file of our GraphQL service, each resolver function begins with five lines of code handling user authentication checks. These lines are responsible for fetching the user ID and type from the context, and conditionally setting the user ID if the user is not an admin. As our authentication processes are now centrally managed by a dedicated authentication service, these checks within the resolver functions are redundant and need to be removed. This cleanup will help in maintaining a cleaner and more focused codebase, ensuring that each component adheres strictly to its designated responsibility.

Here are the lines that need to be removed from each function:

userId := ctx.Value(smodel.QueryKeyUid).(string)
userType := ctx.Value(smodel.QueryKeyUType).(pb_user.UserType)
if userType != pb_user.UserType_UserTypeADMIN {
    user.ID = &userId
}

The changes will be merged into the refactor/team/89/dlr-switch-book first. Therefore, set the base branch of the pull request as refactor/team/89/dlr-switch-book