admin.go 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 form
  5. import (
  6. "github.com/go-macaron/binding"
  7. "gopkg.in/macaron.v1"
  8. )
  9. type AdminCrateUser struct {
  10. LoginType string `binding:"Required"`
  11. LoginName string
  12. UserName string `binding:"Required;AlphaDashDot;MaxSize(35)"`
  13. Email string `binding:"Required;Email;MaxSize(254)"`
  14. Password string `binding:"MaxSize(255)"`
  15. SendNotify bool
  16. }
  17. func (f *AdminCrateUser) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  18. return validate(errs, ctx.Data, f, ctx.Locale)
  19. }
  20. type AdminEditUser struct {
  21. LoginType string `binding:"Required"`
  22. LoginName string
  23. FullName string `binding:"MaxSize(100)"`
  24. Email string `binding:"Required;Email;MaxSize(254)"`
  25. HideEmail bool
  26. Password string `binding:"MaxSize(255)"`
  27. Website string `binding:"MaxSize(50)"`
  28. Location string `binding:"MaxSize(50)"`
  29. MaxRepoCreation int
  30. Active bool
  31. Admin bool
  32. AllowGitHook bool
  33. AllowImportLocal bool
  34. ProhibitLogin bool
  35. }
  36. func (f *AdminEditUser) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  37. return validate(errs, ctx.Data, f, ctx.Locale)
  38. }