diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2022-03-02 23:30:14 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-02 16:30:14 +0100 |
commit | dd712b77f7ccc0e3c3f1872c96dc120c20af0b08 (patch) | |
tree | 6b96634aa6fed42ee7d5ab2862a3f48b8ddafd64 /routers/web/admin/users.go | |
parent | a14b6f3aae196b2506e07f1dcfcd38d338b91e68 (diff) | |
download | gitea-dd712b77f7ccc0e3c3f1872c96dc120c20af0b08.tar.gz gitea-dd712b77f7ccc0e3c3f1872c96dc120c20af0b08.zip |
Refactor admin user filter query parameters (#18965)
Only pass `status_filter` on admin page
Use a more general method to pass query parameters, remove hard-coded keys
Diffstat (limited to 'routers/web/admin/users.go')
-rw-r--r-- | routers/web/admin/users.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/routers/web/admin/users.go b/routers/web/admin/users.go index 4358db89ba..1f304297c0 100644 --- a/routers/web/admin/users.go +++ b/routers/web/admin/users.go @@ -41,10 +41,16 @@ func Users(ctx *context.Context) { ctx.Data["PageIsAdmin"] = true ctx.Data["PageIsAdminUsers"] = true + extraParamStrings := map[string]string{} statusFilterKeys := []string{"is_active", "is_admin", "is_restricted", "is_2fa_enabled", "is_prohibit_login"} statusFilterMap := map[string]string{} for _, filterKey := range statusFilterKeys { - statusFilterMap[filterKey] = ctx.FormString("status_filter[" + filterKey + "]") + paramKey := "status_filter[" + filterKey + "]" + paramVal := ctx.FormString(paramKey) + statusFilterMap[filterKey] = paramVal + if paramVal != "" { + extraParamStrings[paramKey] = paramVal + } } sortType := ctx.FormString("sort") @@ -68,6 +74,7 @@ func Users(ctx *context.Context) { IsRestricted: util.OptionalBoolParse(statusFilterMap["is_restricted"]), IsTwoFactorEnabled: util.OptionalBoolParse(statusFilterMap["is_2fa_enabled"]), IsProhibitLogin: util.OptionalBoolParse(statusFilterMap["is_prohibit_login"]), + ExtraParamStrings: extraParamStrings, }, tplUsers) } |