summaryrefslogtreecommitdiffstats
path: root/routers/admin/users.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/admin/users.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/admin/users.go')
-rw-r--r--routers/admin/users.go15
1 files changed, 8 insertions, 7 deletions
diff --git a/routers/admin/users.go b/routers/admin/users.go
index e3f5692030..13609ac746 100644
--- a/routers/admin/users.go
+++ b/routers/admin/users.go
@@ -7,6 +7,7 @@ package admin
import (
"fmt"
+ "net/http"
"strconv"
"strings"
@@ -60,7 +61,7 @@ func NewUser(ctx *context.Context) {
ctx.Data["Sources"] = sources
ctx.Data["CanSendEmail"] = setting.MailService != nil
- ctx.HTML(200, tplUserNew)
+ ctx.HTML(http.StatusOK, tplUserNew)
}
// NewUserPost response for adding a new user
@@ -80,7 +81,7 @@ func NewUserPost(ctx *context.Context) {
ctx.Data["CanSendEmail"] = setting.MailService != nil
if ctx.HasError() {
- ctx.HTML(200, tplUserNew)
+ ctx.HTML(http.StatusOK, tplUserNew)
return
}
@@ -212,7 +213,7 @@ func EditUser(ctx *context.Context) {
return
}
- ctx.HTML(200, tplUserEdit)
+ ctx.HTML(http.StatusOK, tplUserEdit)
}
// EditUserPost response for editting user
@@ -229,7 +230,7 @@ func EditUserPost(ctx *context.Context) {
}
if ctx.HasError() {
- ctx.HTML(200, tplUserEdit)
+ ctx.HTML(http.StatusOK, tplUserEdit)
return
}
@@ -348,12 +349,12 @@ func DeleteUser(ctx *context.Context) {
switch {
case models.IsErrUserOwnRepos(err):
ctx.Flash.Error(ctx.Tr("admin.users.still_own_repo"))
- ctx.JSON(200, map[string]interface{}{
+ ctx.JSON(http.StatusOK, map[string]interface{}{
"redirect": setting.AppSubURL + "/admin/users/" + ctx.Params(":userid"),
})
case models.IsErrUserHasOrgs(err):
ctx.Flash.Error(ctx.Tr("admin.users.still_has_org"))
- ctx.JSON(200, map[string]interface{}{
+ ctx.JSON(http.StatusOK, map[string]interface{}{
"redirect": setting.AppSubURL + "/admin/users/" + ctx.Params(":userid"),
})
default:
@@ -364,7 +365,7 @@ func DeleteUser(ctx *context.Context) {
log.Trace("Account deleted by admin (%s): %s", ctx.User.Name, u.Name)
ctx.Flash.Success(ctx.Tr("admin.users.deletion_success"))
- ctx.JSON(200, map[string]interface{}{
+ ctx.JSON(http.StatusOK, map[string]interface{}{
"redirect": setting.AppSubURL + "/admin/users",
})
}