code.gitea.io/gitea@v1.21.7/services/forms/admin.go (about) 1 // Copyright 2014 The Gogs Authors. All rights reserved. 2 // SPDX-License-Identifier: MIT 3 4 package forms 5 6 import ( 7 "net/http" 8 9 "code.gitea.io/gitea/modules/context" 10 "code.gitea.io/gitea/modules/structs" 11 "code.gitea.io/gitea/modules/web/middleware" 12 13 "gitea.com/go-chi/binding" 14 ) 15 16 // AdminCreateUserForm form for admin to create user 17 type AdminCreateUserForm struct { 18 LoginType string `binding:"Required"` 19 LoginName string 20 UserName string `binding:"Required;Username;MaxSize(40)"` 21 Email string `binding:"Required;Email;MaxSize(254)"` 22 Password string `binding:"MaxSize(255)"` 23 SendNotify bool 24 MustChangePassword bool 25 Visibility structs.VisibleType 26 } 27 28 // Validate validates form fields 29 func (f *AdminCreateUserForm) Validate(req *http.Request, errs binding.Errors) binding.Errors { 30 ctx := context.GetValidateContext(req) 31 return middleware.Validate(errs, ctx.Data, f, ctx.Locale) 32 } 33 34 // AdminEditUserForm form for admin to create user 35 type AdminEditUserForm struct { 36 LoginType string `binding:"Required"` 37 UserName string `binding:"Username;MaxSize(40)"` 38 LoginName string 39 FullName string `binding:"MaxSize(100)"` 40 Email string `binding:"Required;Email;MaxSize(254)"` 41 Password string `binding:"MaxSize(255)"` 42 Website string `binding:"ValidUrl;MaxSize(255)"` 43 Location string `binding:"MaxSize(50)"` 44 MaxRepoCreation int 45 Active bool 46 Admin bool 47 Restricted bool 48 AllowGitHook bool 49 AllowImportLocal bool 50 AllowCreateOrganization bool 51 ProhibitLogin bool 52 Reset2FA bool `form:"reset_2fa"` 53 Visibility structs.VisibleType 54 } 55 56 // Validate validates form fields 57 func (f *AdminEditUserForm) Validate(req *http.Request, errs binding.Errors) binding.Errors { 58 ctx := context.GetValidateContext(req) 59 return middleware.Validate(errs, ctx.Data, f, ctx.Locale) 60 } 61 62 // AdminDashboardForm form for admin dashboard operations 63 type AdminDashboardForm struct { 64 Op string `binding:"required"` 65 From string 66 } 67 68 // Validate validates form fields 69 func (f *AdminDashboardForm) Validate(req *http.Request, errs binding.Errors) binding.Errors { 70 ctx := context.GetValidateContext(req) 71 return middleware.Validate(errs, ctx.Data, f, ctx.Locale) 72 }