aboutsummaryrefslogtreecommitdiffstats
path: root/routers/org/members.go
diff options
context:
space:
mode:
author6543 <6543@obermui.de>2021-04-05 17:30:52 +0200
committerGitHub <noreply@github.com>2021-04-05 11:30:52 -0400
commit16dea6cebd375fc274fc7a9c216dbcc9e22bd5c7 (patch)
tree75d47012e9899ca24408aeef7fa3adfcd4beaed1 /routers/org/members.go
parente9fba18a26c9d0f8586254a83ef7afcd293a725a (diff)
downloadgitea-16dea6cebd375fc274fc7a9c216dbcc9e22bd5c7.tar.gz
gitea-16dea6cebd375fc274fc7a9c216dbcc9e22bd5c7.zip
[refactor] replace int with httpStatusCodes (#15282)
* replace "200" (int) with "http.StatusOK" (const) * ctx.Error & ctx.HTML * ctx.JSON Part1 * ctx.JSON Part2 * ctx.JSON Part3
Diffstat (limited to 'routers/org/members.go')
-rw-r--r--routers/org/members.go16
1 files changed, 9 insertions, 7 deletions
diff --git a/routers/org/members.go b/routers/org/members.go
index 00ca381ad0..934529d7d7 100644
--- a/routers/org/members.go
+++ b/routers/org/members.go
@@ -6,6 +6,8 @@
package org
import (
+ "net/http"
+
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/base"
"code.gitea.io/gitea/modules/context"
@@ -37,7 +39,7 @@ func Members(ctx *context.Context) {
if ctx.User != nil {
isMember, err := ctx.Org.Organization.IsOrgMember(ctx.User.ID)
if err != nil {
- ctx.Error(500, "IsOrgMember")
+ ctx.Error(http.StatusInternalServerError, "IsOrgMember")
return
}
opts.PublicOnly = !isMember && !ctx.User.IsAdmin
@@ -45,7 +47,7 @@ func Members(ctx *context.Context) {
total, err := models.CountOrgMembers(opts)
if err != nil {
- ctx.Error(500, "CountOrgMembers")
+ ctx.Error(http.StatusInternalServerError, "CountOrgMembers")
return
}
@@ -63,7 +65,7 @@ func Members(ctx *context.Context) {
ctx.Data["MembersIsUserOrgOwner"] = members.IsUserOrgOwner(org.ID)
ctx.Data["MembersTwoFaStatus"] = members.GetTwoFaStatus()
- ctx.HTML(200, tplMembers)
+ ctx.HTML(http.StatusOK, tplMembers)
}
// MembersAction response for operation to a member of organization
@@ -79,19 +81,19 @@ func MembersAction(ctx *context.Context) {
switch ctx.Params(":action") {
case "private":
if ctx.User.ID != uid && !ctx.Org.IsOwner {
- ctx.Error(404)
+ ctx.Error(http.StatusNotFound)
return
}
err = models.ChangeOrgUserStatus(org.ID, uid, false)
case "public":
if ctx.User.ID != uid && !ctx.Org.IsOwner {
- ctx.Error(404)
+ ctx.Error(http.StatusNotFound)
return
}
err = models.ChangeOrgUserStatus(org.ID, uid, true)
case "remove":
if !ctx.Org.IsOwner {
- ctx.Error(404)
+ ctx.Error(http.StatusNotFound)
return
}
err = org.RemoveMember(uid)
@@ -111,7 +113,7 @@ func MembersAction(ctx *context.Context) {
if err != nil {
log.Error("Action(%s): %v", ctx.Params(":action"), err)
- ctx.JSON(200, map[string]interface{}{
+ ctx.JSON(http.StatusOK, map[string]interface{}{
"ok": false,
"err": err.Error(),
})