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.

48 lines
1.5 KiB

  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. // 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(35)"`
  14. Email string `binding:"Required;Email;MaxSize(254)"`
  15. Password string `binding:"MaxSize(255)"`
  16. SendNotify bool
  17. }
  18. // Validate validates form fields
  19. func (f *AdminCreateUserForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  20. return validate(errs, ctx.Data, f, ctx.Locale)
  21. }
  22. // AdminEditUserForm form for admin to create user
  23. type AdminEditUserForm struct {
  24. LoginType string `binding:"Required"`
  25. LoginName string
  26. FullName string `binding:"MaxSize(100)"`
  27. Email string `binding:"Required;Email;MaxSize(254)"`
  28. Password string `binding:"MaxSize(255)"`
  29. Website string `binding:"MaxSize(50)"`
  30. Location string `binding:"MaxSize(50)"`
  31. MaxRepoCreation int
  32. Active bool
  33. Admin bool
  34. AllowGitHook bool
  35. AllowImportLocal bool
  36. ProhibitLogin bool
  37. }
  38. // Validate validates form fields
  39. func (f *AdminEditUserForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
  40. return validate(errs, ctx.Data, f, ctx.Locale)
  41. }