-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Open
Labels
topic/apiConcerns mainly the APIConcerns mainly the APItype/featureCompletely new functionality. Can only be merged if feature freeze is not active.Completely new functionality. Can only be merged if feature freeze is not active.type/proposalThe new feature has not been accepted yet but needs to be discussed first.The new feature has not been accepted yet but needs to be discussed first.
Description
Feature Description
It seems that we only have Team.Authorize
before #17811, so maybe Team.Authorize
is unnecessary now?
If it is unnecessary, maybe we need to do some changes to GetUserOrgsPermissions
too?
gitea/routers/api/v1/org/org.go
Lines 105 to 169 in 6706ac2
func GetUserOrgsPermissions(ctx *context.APIContext) { | |
// swagger:operation GET /users/{username}/orgs/{org}/permissions organization orgGetUserPermissions | |
// --- | |
// summary: Get user permissions in organization | |
// produces: | |
// - application/json | |
// parameters: | |
// - name: username | |
// in: path | |
// description: username of user | |
// type: string | |
// required: true | |
// - name: org | |
// in: path | |
// description: name of the organization | |
// type: string | |
// required: true | |
// responses: | |
// "200": | |
// "$ref": "#/responses/OrganizationPermissions" | |
// "403": | |
// "$ref": "#/responses/forbidden" | |
// "404": | |
// "$ref": "#/responses/notFound" | |
var o *user_model.User | |
if o = user.GetUserByParamsName(ctx, ":org"); o == nil { | |
return | |
} | |
op := api.OrganizationPermissions{} | |
if !organization.HasOrgOrUserVisible(ctx, o, ctx.ContextUser) { | |
ctx.NotFound("HasOrgOrUserVisible", nil) | |
return | |
} | |
org := organization.OrgFromUser(o) | |
authorizeLevel, err := org.GetOrgUserMaxAuthorizeLevel(ctx.ContextUser.ID) | |
if err != nil { | |
ctx.Error(http.StatusInternalServerError, "GetOrgUserAuthorizeLevel", err) | |
return | |
} | |
if authorizeLevel > perm.AccessModeNone { | |
op.CanRead = true | |
} | |
if authorizeLevel > perm.AccessModeRead { | |
op.CanWrite = true | |
} | |
if authorizeLevel > perm.AccessModeWrite { | |
op.IsAdmin = true | |
} | |
if authorizeLevel > perm.AccessModeAdmin { | |
op.IsOwner = true | |
} | |
op.CanCreateRepository, err = org.CanCreateOrgRepo(ctx.ContextUser.ID) | |
if err != nil { | |
ctx.Error(http.StatusInternalServerError, "CanCreateOrgRepo", err) | |
return | |
} | |
ctx.JSON(http.StatusOK, op) | |
} |
origin comment: #23729 (comment)
Screenshots
No response
Metadata
Metadata
Assignees
Labels
topic/apiConcerns mainly the APIConcerns mainly the APItype/featureCompletely new functionality. Can only be merged if feature freeze is not active.Completely new functionality. Can only be merged if feature freeze is not active.type/proposalThe new feature has not been accepted yet but needs to be discussed first.The new feature has not been accepted yet but needs to be discussed first.