-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Fix repo API bug #2133
Fix repo API bug #2133
Conversation
routers/api/v1/api.go
Outdated
}) | ||
m.Group("/:index", func() { | ||
m.Combo("").Get(repo.GetIssue).Patch(bind(api.EditIssueOption{}), repo.EditIssue) | ||
m.Combo("").Get(repo.GetIssue). | ||
Patch(reqToken(), bind(api.EditIssueOption{}), repo.EditIssue) | ||
|
||
m.Group("/comments", func() { | ||
m.Combo("").Get(repo.ListIssueComments).Post(bind(api.CreateIssueCommentOption{}), repo.CreateIssueComment) |
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.
.Post
should have reqToken()
:)
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.
@bkcsoft Good catch, fixed.
LGTM (just need rebase) |
import "code.gitea.io/gitea/modules/context" | ||
|
||
// UserID user ID of authenticated user, or 0 if not authenticated | ||
func UserID(ctx *context.APIContext) int64 { |
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.
I would prefer the definition of a method like models.UserAccessLevel(ctx.User, repo) that check :
if ctx.User == nil { ...
an return models.AccessLevel
Don't require token when not necessary
91463b8
to
3f0efdc
Compare
Rebased to resolve conflict |
LGTM |
Don't require authentication for some
GET
API endpoints (e.g.GET /repos/:owner/:repo
,GET /repos/:owner/:repo/issues
, ...) whose corresponding Github endpoints do not require authentication.Also add integration tests for some of the affected endpoints.