summaryrefslogtreecommitdiffstats
path: root/routers/api/v1/org
diff options
context:
space:
mode:
authorKN4CK3R <admin@oldschoolhack.me>2022-03-22 08:03:22 +0100
committerGitHub <noreply@github.com>2022-03-22 15:03:22 +0800
commit80fd25524e13dedbdc3527b32d008de152213a89 (patch)
tree63b2bfe4ffaf1dce12080cabdc2e845c8731a673 /routers/api/v1/org
parent5495ba7660979973ba19e304786135da474e0e64 (diff)
downloadgitea-80fd25524e13dedbdc3527b32d008de152213a89.tar.gz
gitea-80fd25524e13dedbdc3527b32d008de152213a89.zip
Renamed ctx.User to ctx.Doer. (#19161)
Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'routers/api/v1/org')
-rw-r--r--routers/api/v1/org/member.go20
-rw-r--r--routers/api/v1/org/org.go14
-rw-r--r--routers/api/v1/org/team.go16
3 files changed, 25 insertions, 25 deletions
diff --git a/routers/api/v1/org/member.go b/routers/api/v1/org/member.go
index d818321790..7f82f19385 100644
--- a/routers/api/v1/org/member.go
+++ b/routers/api/v1/org/member.go
@@ -39,7 +39,7 @@ func listMembers(ctx *context.APIContext, publicOnly bool) {
apiMembers := make([]*api.User, len(members))
for i, member := range members {
- apiMembers[i] = convert.ToUser(member, ctx.User)
+ apiMembers[i] = convert.ToUser(member, ctx.Doer)
}
ctx.SetTotalCountHeader(count)
@@ -72,13 +72,13 @@ func ListMembers(ctx *context.APIContext) {
// "$ref": "#/responses/UserList"
publicOnly := true
- if ctx.User != nil {
- isMember, err := ctx.Org.Organization.IsOrgMember(ctx.User.ID)
+ if ctx.Doer != nil {
+ isMember, err := ctx.Org.Organization.IsOrgMember(ctx.Doer.ID)
if err != nil {
ctx.Error(http.StatusInternalServerError, "IsOrgMember", err)
return
}
- publicOnly = !isMember && !ctx.User.IsAdmin
+ publicOnly = !isMember && !ctx.Doer.IsAdmin
}
listMembers(ctx, publicOnly)
}
@@ -139,12 +139,12 @@ func IsMember(ctx *context.APIContext) {
if ctx.Written() {
return
}
- if ctx.User != nil {
- userIsMember, err := ctx.Org.Organization.IsOrgMember(ctx.User.ID)
+ if ctx.Doer != nil {
+ userIsMember, err := ctx.Org.Organization.IsOrgMember(ctx.Doer.ID)
if err != nil {
ctx.Error(http.StatusInternalServerError, "IsOrgMember", err)
return
- } else if userIsMember || ctx.User.IsAdmin {
+ } else if userIsMember || ctx.Doer.IsAdmin {
userToCheckIsMember, err := ctx.Org.Organization.IsOrgMember(userToCheck.ID)
if err != nil {
ctx.Error(http.StatusInternalServerError, "IsOrgMember", err)
@@ -154,7 +154,7 @@ func IsMember(ctx *context.APIContext) {
ctx.NotFound()
}
return
- } else if ctx.User.ID == userToCheck.ID {
+ } else if ctx.Doer.ID == userToCheck.ID {
ctx.NotFound()
return
}
@@ -230,7 +230,7 @@ func PublicizeMember(ctx *context.APIContext) {
if ctx.Written() {
return
}
- if userToPublicize.ID != ctx.User.ID {
+ if userToPublicize.ID != ctx.Doer.ID {
ctx.Error(http.StatusForbidden, "", "Cannot publicize another member")
return
}
@@ -270,7 +270,7 @@ func ConcealMember(ctx *context.APIContext) {
if ctx.Written() {
return
}
- if userToConceal.ID != ctx.User.ID {
+ if userToConceal.ID != ctx.Doer.ID {
ctx.Error(http.StatusForbidden, "", "Cannot conceal another member")
return
}
diff --git a/routers/api/v1/org/org.go b/routers/api/v1/org/org.go
index 1f097225f2..a920b49a84 100644
--- a/routers/api/v1/org/org.go
+++ b/routers/api/v1/org/org.go
@@ -23,7 +23,7 @@ import (
func listUserOrgs(ctx *context.APIContext, u *user_model.User) {
listOptions := utils.GetListOptions(ctx)
- showPrivate := ctx.IsSigned && (ctx.User.IsAdmin || ctx.User.ID == u.ID)
+ showPrivate := ctx.IsSigned && (ctx.Doer.IsAdmin || ctx.Doer.ID == u.ID)
opts := models.FindOrgOptions{
ListOptions: listOptions,
@@ -71,7 +71,7 @@ func ListMyOrgs(ctx *context.APIContext) {
// "200":
// "$ref": "#/responses/OrganizationList"
- listUserOrgs(ctx, ctx.User)
+ listUserOrgs(ctx, ctx.Doer)
}
// ListUserOrgs list user's orgs
@@ -201,7 +201,7 @@ func GetAll(ctx *context.APIContext) {
vMode := []api.VisibleType{api.VisibleTypePublic}
if ctx.IsSigned {
vMode = append(vMode, api.VisibleTypeLimited)
- if ctx.User.IsAdmin {
+ if ctx.Doer.IsAdmin {
vMode = append(vMode, api.VisibleTypePrivate)
}
}
@@ -209,7 +209,7 @@ func GetAll(ctx *context.APIContext) {
listOptions := utils.GetListOptions(ctx)
publicOrgs, maxResults, err := user_model.SearchUsers(&user_model.SearchUserOptions{
- Actor: ctx.User,
+ Actor: ctx.Doer,
ListOptions: listOptions,
Type: user_model.UserTypeOrganization,
OrderBy: db.SearchOrderByAlphabetically,
@@ -251,7 +251,7 @@ func Create(ctx *context.APIContext) {
// "422":
// "$ref": "#/responses/validationError"
form := web.GetForm(ctx).(*api.CreateOrgOption)
- if !ctx.User.CanCreateOrganization() {
+ if !ctx.Doer.CanCreateOrganization() {
ctx.Error(http.StatusForbidden, "Create organization not allowed", nil)
return
}
@@ -272,7 +272,7 @@ func Create(ctx *context.APIContext) {
Visibility: visibility,
RepoAdminChangeTeamAccess: form.RepoAdminChangeTeamAccess,
}
- if err := models.CreateOrganization(org, ctx.User); err != nil {
+ if err := models.CreateOrganization(org, ctx.Doer); err != nil {
if user_model.IsErrUserAlreadyExist(err) ||
db.IsErrNameReserved(err) ||
db.IsErrNameCharsNotAllowed(err) ||
@@ -304,7 +304,7 @@ func Get(ctx *context.APIContext) {
// "200":
// "$ref": "#/responses/Organization"
- if !models.HasOrgOrUserVisible(ctx.Org.Organization.AsUser(), ctx.User) {
+ if !models.HasOrgOrUserVisible(ctx.Org.Organization.AsUser(), ctx.Doer) {
ctx.NotFound("HasOrgOrUserVisible", nil)
return
}
diff --git a/routers/api/v1/org/team.go b/routers/api/v1/org/team.go
index 62e6c0a6b4..ca8cda269a 100644
--- a/routers/api/v1/org/team.go
+++ b/routers/api/v1/org/team.go
@@ -92,7 +92,7 @@ func ListUserTeams(ctx *context.APIContext) {
teams, count, err := models.GetUserTeams(&models.GetUserTeamOptions{
ListOptions: utils.GetListOptions(ctx),
- UserID: ctx.User.ID,
+ UserID: ctx.Doer.ID,
})
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetUserTeams", err)
@@ -368,11 +368,11 @@ func GetTeamMembers(ctx *context.APIContext) {
// "200":
// "$ref": "#/responses/UserList"
- isMember, err := models.IsOrganizationMember(ctx.Org.Team.OrgID, ctx.User.ID)
+ isMember, err := models.IsOrganizationMember(ctx.Org.Team.OrgID, ctx.Doer.ID)
if err != nil {
ctx.Error(http.StatusInternalServerError, "IsOrganizationMember", err)
return
- } else if !isMember && !ctx.User.IsAdmin {
+ } else if !isMember && !ctx.Doer.IsAdmin {
ctx.NotFound()
return
}
@@ -385,7 +385,7 @@ func GetTeamMembers(ctx *context.APIContext) {
}
members := make([]*api.User, len(ctx.Org.Team.Members))
for i, member := range ctx.Org.Team.Members {
- members[i] = convert.ToUser(member, ctx.User)
+ members[i] = convert.ToUser(member, ctx.Doer)
}
ctx.SetTotalCountHeader(int64(ctx.Org.Team.NumMembers))
@@ -430,7 +430,7 @@ func GetTeamMember(ctx *context.APIContext) {
ctx.NotFound()
return
}
- ctx.JSON(http.StatusOK, convert.ToUser(u, ctx.User))
+ ctx.JSON(http.StatusOK, convert.ToUser(u, ctx.Doer))
}
// AddTeamMember api for add a member to a team
@@ -540,7 +540,7 @@ func GetTeamRepos(ctx *context.APIContext) {
}
repos := make([]*api.Repository, len(team.Repos))
for i, repo := range team.Repos {
- access, err := models.AccessLevel(ctx.User, repo)
+ access, err := models.AccessLevel(ctx.Doer, repo)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetTeamRepos", err)
return
@@ -599,7 +599,7 @@ func AddTeamRepository(ctx *context.APIContext) {
if ctx.Written() {
return
}
- if access, err := models.AccessLevel(ctx.User, repo); err != nil {
+ if access, err := models.AccessLevel(ctx.Doer, repo); err != nil {
ctx.Error(http.StatusInternalServerError, "AccessLevel", err)
return
} else if access < perm.AccessModeAdmin {
@@ -649,7 +649,7 @@ func RemoveTeamRepository(ctx *context.APIContext) {
if ctx.Written() {
return
}
- if access, err := models.AccessLevel(ctx.User, repo); err != nil {
+ if access, err := models.AccessLevel(ctx.Doer, repo); err != nil {
ctx.Error(http.StatusInternalServerError, "AccessLevel", err)
return
} else if access < perm.AccessModeAdmin {