Skip to content
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

Merged
merged 2 commits into from Jul 12, 2017
Merged

Fix repo API bug #2133

merged 2 commits into from Jul 12, 2017

Conversation

ethantkoenig
Copy link
Member

@ethantkoenig ethantkoenig commented Jul 9, 2017

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.

})
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.Post should have reqToken() :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bkcsoft Good catch, fixed.

@lunny lunny added this to the 1.2.0 milestone Jul 10, 2017
@lunny lunny added the type/bug label Jul 10, 2017
@sapk
Copy link
Member

sapk commented Jul 10, 2017

LGTM (just need rebase)

@tboerger tboerger added the lgtm/need 1 This PR needs approval from one additional maintainer to be merged. label Jul 10, 2017
import "code.gitea.io/gitea/modules/context"

// UserID user ID of authenticated user, or 0 if not authenticated
func UserID(ctx *context.APIContext) int64 {
Copy link
Member

@sapk sapk Jul 10, 2017

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
@ethantkoenig
Copy link
Member Author

Rebased to resolve conflict

@bkcsoft
Copy link
Member

bkcsoft commented Jul 12, 2017

LGTM

@tboerger tboerger added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Jul 12, 2017
@bkcsoft bkcsoft merged commit 93a1de4 into go-gitea:master Jul 12, 2017
@ethantkoenig ethantkoenig deleted the fix/repo_api branch July 29, 2017 17:13
@go-gitea go-gitea locked and limited conversation to collaborators Nov 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants