2014-03-21 15:45:58 +05:30
|
|
|
// Copyright 2014 The Gogs Authors. All rights reserved.
|
2022-11-27 23:50:29 +05:30
|
|
|
// SPDX-License-Identifier: MIT
|
2014-03-21 15:45:58 +05:30
|
|
|
|
2021-01-26 21:06:53 +05:30
|
|
|
package forms
|
2014-03-21 15:45:58 +05:30
|
|
|
|
|
|
|
import (
|
2021-01-26 21:06:53 +05:30
|
|
|
"net/http"
|
|
|
|
|
2021-06-27 01:23:14 +05:30
|
|
|
"code.gitea.io/gitea/modules/structs"
|
2021-01-30 14:25:53 +05:30
|
|
|
"code.gitea.io/gitea/modules/web/middleware"
|
2024-02-27 12:42:22 +05:30
|
|
|
"code.gitea.io/gitea/services/context"
|
2021-01-26 21:06:53 +05:30
|
|
|
|
|
|
|
"gitea.com/go-chi/binding"
|
2014-03-21 15:45:58 +05:30
|
|
|
)
|
|
|
|
|
2016-11-27 11:33:59 +05:30
|
|
|
// AdminCreateUserForm form for admin to create user
|
|
|
|
type AdminCreateUserForm struct {
|
2018-09-13 22:04:36 +05:30
|
|
|
LoginType string `binding:"Required"`
|
|
|
|
LoginName string
|
2022-11-04 14:34:08 +05:30
|
|
|
UserName string `binding:"Required;Username;MaxSize(40)"`
|
2018-09-13 22:04:36 +05:30
|
|
|
Email string `binding:"Required;Email;MaxSize(254)"`
|
|
|
|
Password string `binding:"MaxSize(255)"`
|
|
|
|
SendNotify bool
|
|
|
|
MustChangePassword bool
|
2021-06-27 01:23:14 +05:30
|
|
|
Visibility structs.VisibleType
|
2015-09-13 20:37:21 +05:30
|
|
|
}
|
|
|
|
|
2016-11-27 11:33:59 +05:30
|
|
|
// Validate validates form fields
|
2021-01-26 21:06:53 +05:30
|
|
|
func (f *AdminCreateUserForm) Validate(req *http.Request, errs binding.Errors) binding.Errors {
|
2023-05-21 07:20:53 +05:30
|
|
|
ctx := context.GetValidateContext(req)
|
2021-01-30 14:25:53 +05:30
|
|
|
return middleware.Validate(errs, ctx.Data, f, ctx.Locale)
|
2015-09-13 20:37:21 +05:30
|
|
|
}
|
|
|
|
|
2016-11-27 11:33:59 +05:30
|
|
|
// AdminEditUserForm form for admin to create user
|
2014-03-21 15:45:58 +05:30
|
|
|
type AdminEditUserForm struct {
|
2016-12-31 08:03:30 +05:30
|
|
|
LoginType string `binding:"Required"`
|
2022-11-04 14:34:08 +05:30
|
|
|
UserName string `binding:"Username;MaxSize(40)"`
|
2016-12-31 08:03:30 +05:30
|
|
|
LoginName string
|
|
|
|
FullName string `binding:"MaxSize(100)"`
|
|
|
|
Email string `binding:"Required;Email;MaxSize(254)"`
|
|
|
|
Password string `binding:"MaxSize(255)"`
|
2017-04-19 08:32:20 +05:30
|
|
|
Website string `binding:"ValidUrl;MaxSize(255)"`
|
2016-12-31 08:03:30 +05:30
|
|
|
Location string `binding:"MaxSize(50)"`
|
2024-03-03 03:25:02 +05:30
|
|
|
Language string `binding:"MaxSize(5)"`
|
2024-02-29 18:25:52 +05:30
|
|
|
Pronouns string `binding:"MaxSize(50)"`
|
2016-12-31 08:03:30 +05:30
|
|
|
MaxRepoCreation int
|
|
|
|
Active bool
|
|
|
|
Admin bool
|
2020-01-13 23:03:46 +05:30
|
|
|
Restricted bool
|
2016-12-31 08:03:30 +05:30
|
|
|
AllowGitHook bool
|
|
|
|
AllowImportLocal bool
|
|
|
|
AllowCreateOrganization bool
|
|
|
|
ProhibitLogin bool
|
2021-01-05 19:24:48 +05:30
|
|
|
Reset2FA bool `form:"reset_2fa"`
|
2021-06-27 01:23:14 +05:30
|
|
|
Visibility structs.VisibleType
|
2014-03-21 15:45:58 +05:30
|
|
|
}
|
|
|
|
|
2016-11-27 11:33:59 +05:30
|
|
|
// Validate validates form fields
|
2021-01-26 21:06:53 +05:30
|
|
|
func (f *AdminEditUserForm) Validate(req *http.Request, errs binding.Errors) binding.Errors {
|
2023-05-21 07:20:53 +05:30
|
|
|
ctx := context.GetValidateContext(req)
|
2021-01-30 14:25:53 +05:30
|
|
|
return middleware.Validate(errs, ctx.Data, f, ctx.Locale)
|
2014-03-21 15:45:58 +05:30
|
|
|
}
|
2020-02-26 04:24:13 +05:30
|
|
|
|
|
|
|
// AdminDashboardForm form for admin dashboard operations
|
|
|
|
type AdminDashboardForm struct {
|
2020-07-06 01:08:03 +05:30
|
|
|
Op string `binding:"required"`
|
|
|
|
From string
|
2020-02-26 04:24:13 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
// Validate validates form fields
|
2021-01-26 21:06:53 +05:30
|
|
|
func (f *AdminDashboardForm) Validate(req *http.Request, errs binding.Errors) binding.Errors {
|
2023-05-21 07:20:53 +05:30
|
|
|
ctx := context.GetValidateContext(req)
|
2021-01-30 14:25:53 +05:30
|
|
|
return middleware.Validate(errs, ctx.Data, f, ctx.Locale)
|
2020-02-26 04:24:13 +05:30
|
|
|
}
|