admin.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. "net/http"
  7. "reflect"
  8. "github.com/go-martini/martini"
  9. "github.com/gogits/gogs/modules/base"
  10. "github.com/gogits/gogs/modules/middleware/binding"
  11. )
  12. type AdminEditUserForm struct {
  13. Email string `form:"email" binding:"Required;Email;MaxSize(50)"`
  14. Passwd string `form:"passwd"`
  15. Website string `form:"website" binding:"MaxSize(50)"`
  16. Location string `form:"location" binding:"MaxSize(50)"`
  17. Avatar string `form:"avatar" binding:"Required;Email;MaxSize(50)"`
  18. Active bool `form:"active"`
  19. Admin bool `form:"admin"`
  20. LoginType int `form:"login_type"`
  21. }
  22. func (f *AdminEditUserForm) Name(field string) string {
  23. names := map[string]string{
  24. "Email": "E-mail address",
  25. "Website": "Website",
  26. "Location": "Location",
  27. "Avatar": "Gravatar Email",
  28. }
  29. return names[field]
  30. }
  31. func (f *AdminEditUserForm) Validate(errors *binding.Errors, req *http.Request, context martini.Context) {
  32. data := context.Get(reflect.TypeOf(base.TmplData{})).Interface().(base.TmplData)
  33. validate(errors, data, f)
  34. }