admin.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. Password string `binding:"MaxSize(255)"`
  26. Website string `binding:"MaxSize(50)"`
  27. Location string `binding:"MaxSize(50)"`
  28. MaxRepoCreation int
  29. Active bool
  30. Admin bool
  31. AllowGitHook bool
  32. AllowImportLocal bool
  33. ProhibitLogin bool
  34. }
  35. func (f *AdminEditUser) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  36. return validate(errs, ctx.Data, f, ctx.Locale)
  37. }