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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. AllowGitHook bool
  36. AllowImportLocal bool
  37. AllowCreateOrganization bool
  38. ProhibitLogin bool
  39. }
  40. // Validate validates form fields
  41. func (f *AdminEditUserForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  42. return validate(errs, ctx.Data, f, ctx.Locale)
  43. }
  44. // AdminDashboardForm form for admin dashboard operations
  45. type AdminDashboardForm struct {
  46. Op int `binding:"required"`
  47. }
  48. // Validate validates form fields
  49. func (f *AdminDashboardForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  50. return validate(errs, ctx.Data, f, ctx.Locale)
  51. }