@@ -65,23 +65,26 @@ func VerifyToken(cfg Options) func(next http.Handler) http.Handler {
6565 if cfg .ProjectStore != nil {
6666 projectID , err := findProjectClaim (r )
6767 if err != nil {
68- cfg .ErrHandler (r , w , proto .ErrUnauthorized .WithCausef ("get project claim: %w" , err ))
68+ cfg .ErrHandler (r , w , proto .ErrUnauthorized .WithCausef ("find project claim: %w" , err ))
6969 return
7070 }
7171
72- project , _auth , err := cfg .ProjectStore .GetProject (ctx , projectID )
73- if err != nil {
74- cfg .ErrHandler (r , w , proto .ErrUnauthorized .WithCausef ("get project: %w" , err ))
75- return
76- }
77- if project == nil {
78- cfg .ErrHandler (r , w , proto .ErrProjectNotFound )
79- return
80- }
81- if _auth != nil {
82- auth = _auth
72+ if projectID != 0 {
73+ project , _auth , err := cfg .ProjectStore .GetProject (ctx , projectID )
74+ if err != nil {
75+ cfg .ErrHandler (r , w , proto .ErrUnauthorized .WithCausef ("get project: %w" , err ))
76+ return
77+ }
78+ if project == nil {
79+ cfg .ErrHandler (r , w , proto .ErrProjectNotFound )
80+ return
81+ }
82+ if _auth != nil {
83+ auth = _auth
84+ }
85+ ctx = WithProject (ctx , project )
8386 }
84- ctx = WithProject ( ctx , project )
87+
8588 }
8689
8790 jwtAuth , err := auth .GetVerifier (jwtOptions ... )
0 commit comments