// ListCollaborators list a repository's collaborators
func ListCollaborators(ctx *context.APIContext) {
- access, err := models.AccessLevel(ctx.User, ctx.Repo.Repository)
- if err != nil {
- ctx.Error(500, "AccessLevel", err)
- return
- }
- if access < models.AccessModeWrite {
+ if !ctx.Repo.IsWriter() {
ctx.Error(403, "", "User does not have push access")
return
}
// IsCollaborator check if a user is a collaborator of a repository
func IsCollaborator(ctx *context.APIContext) {
- access, err := models.AccessLevel(ctx.User, ctx.Repo.Repository)
- if err != nil {
- ctx.Error(500, "AccessLevel", err)
- return
- }
- if access < models.AccessModeWrite {
+ if !ctx.Repo.IsWriter() {
ctx.Error(403, "", "User does not have push access")
return
}
// AddCollaborator add a collaborator of a repository
func AddCollaborator(ctx *context.APIContext, form api.AddCollaboratorOption) {
- access, err := models.AccessLevel(ctx.User, ctx.Repo.Repository)
- if err != nil {
- ctx.Error(500, "AccessLevel", err)
- return
- }
- if access < models.AccessModeWrite {
+ if !ctx.Repo.IsWriter() {
ctx.Error(403, "", "User does not have push access")
return
}
// DeleteCollaborator delete a collaborator from a repository
func DeleteCollaborator(ctx *context.APIContext) {
- access, err := models.AccessLevel(ctx.User, ctx.Repo.Repository)
- if err != nil {
- ctx.Error(500, "AccessLevel", err)
- return
- }
- if access < models.AccessModeWrite {
+ if !ctx.Repo.IsWriter() {
ctx.Error(403, "", "User does not have push access")
return
}