You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

admin.go 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // Copyright 2014 The Gogs Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package auth
  5. import (
  6. "gitea.com/macaron/binding"
  7. "gitea.com/macaron/macaron"
  8. )
  9. // AdminCreateUserForm form for admin to create user
  10. type AdminCreateUserForm struct {
  11. LoginType string `binding:"Required"`
  12. LoginName string
  13. UserName string `binding:"Required;AlphaDashDot;MaxSize(40)"`
  14. Email string `binding:"Required;Email;MaxSize(254)"`
  15. Password string `binding:"MaxSize(255)"`
  16. SendNotify bool
  17. MustChangePassword bool
  18. }
  19. // Validate validates form fields
  20. func (f *AdminCreateUserForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  21. return validate(errs, ctx.Data, f, ctx.Locale)
  22. }
  23. // AdminEditUserForm form for admin to create user
  24. type AdminEditUserForm struct {
  25. LoginType string `binding:"Required"`
  26. LoginName string
  27. FullName string `binding:"MaxSize(100)"`
  28. Email string `binding:"Required;Email;MaxSize(254)"`
  29. Password string `binding:"MaxSize(255)"`
  30. Website string `binding:"ValidUrl;MaxSize(255)"`
  31. Location string `binding:"MaxSize(50)"`
  32. MaxRepoCreation int
  33. Active bool
  34. Admin bool
  35. Restricted bool
  36. AllowGitHook bool
  37. AllowImportLocal bool
  38. AllowCreateOrganization bool
  39. ProhibitLogin bool
  40. }
  41. // Validate validates form fields
  42. func (f *AdminEditUserForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  43. return validate(errs, ctx.Data, f, ctx.Locale)
  44. }
  45. // AdminDashboardForm form for admin dashboard operations
  46. type AdminDashboardForm struct {
  47. Op string `binding:"required"`
  48. }
  49. // Validate validates form fields
  50. func (f *AdminDashboardForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  51. return validate(errs, ctx.Data, f, ctx.Locale)
  52. }