fix: use typed context key instead of string literal- Add UserContextKey constant to types package- Replace bare string 'user' with types.UserContextKey in auth middleware- Update user service to use UserContextKey for context value retrieval- Fixes staticcheck SA1029 warningThis prevents potential context key collisions.
This commit is contained in:
@@ -419,7 +419,7 @@ func (s *userService) RevokeToken(ctx context.Context, tokenString string) error
|
||||
|
||||
// GetCurrentUser gets current user from context
|
||||
func (s *userService) GetCurrentUser(ctx context.Context) (*types.User, error) {
|
||||
user, ok := ctx.Value("user").(*types.User)
|
||||
user, ok := ctx.Value(types.UserContextKey).(*types.User)
|
||||
if !ok {
|
||||
return nil, errors.New("user not found in context")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user