-
-
Notifications
You must be signed in to change notification settings - Fork 363
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
Use middleware to load org #4208
base: main
Are you sure you want to change the base?
Conversation
Deploying preview to https://woodpecker-ci-woodpecker-pr-4208.surge.sh |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4208 +/- ##
==========================================
+ Coverage 26.47% 26.52% +0.05%
==========================================
Files 376 377 +1
Lines 27465 27426 -39
==========================================
+ Hits 7270 7275 +5
+ Misses 19530 19486 -44
Partials 665 665 ☔ View full report in Codecov by Sentry. |
) | ||
|
||
func Org(c *gin.Context) *model.Org { | ||
v, ok := c.Get("org") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one only works now if MustOrg
was called previously?!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes as with other middleware ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's a feature not a bug ... I understand that it could be frigned if you just read the functions behind endpints ... but we do the dame to ensure permissions are set and respected etc ...
... this decuples the endpoint function a bit and also allow tests to be more easy to write agains it ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but we do the dame to ensure permissions are set and respected etc ...
Actually not, we always call SetUser
, SetPerm
, SetRepo
as in https://github.com/anbraten/woodpecker/blob/46f4c589421a790f98ff9759d230b6428b6312e8/server/router/api.go#L91-L92 in the router to add sth to the context and later on, load it using MustUser
or User
.
Should I push the change to show you what I mean?
close #4207