admin.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. "gopkg.in/macaron.v1"
  7. "github.com/go-macaron/binding"
  8. )
  9. type AdminCrateUserForm 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 *AdminCrateUserForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  18. return validate(errs, ctx.Data, f, ctx.Locale)
  19. }
  20. type AdminEditUserForm struct {
  21. LoginType string `binding:"Required"`
  22. LoginName string
  23. FullName string `binding:"MaxSize(100)"`
  24. Email string `binding:"Required;Email;MaxSize(254)"`
  25. ShowEmail 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 *AdminEditUserForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  37. return validate(errs, ctx.Data, f, ctx.Locale)
  38. }