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.

40 lines
1.2 KiB

10 years ago
10 years ago
10 years ago
  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. Website string `form:"website" binding:"MaxSize(50)"`
  15. Location string `form:"location" binding:"MaxSize(50)"`
  16. Avatar string `form:"avatar" binding:"Required;Email;MaxSize(50)"`
  17. Active bool `form:"active"`
  18. Admin bool `form:"admin"`
  19. LoginType int `form:"login_type"`
  20. }
  21. func (f *AdminEditUserForm) Name(field string) string {
  22. names := map[string]string{
  23. "Email": "E-mail address",
  24. "Website": "Website",
  25. "Location": "Location",
  26. "Avatar": "Gravatar Email",
  27. }
  28. return names[field]
  29. }
  30. func (f *AdminEditUserForm) Validate(errors *binding.Errors, req *http.Request, context martini.Context) {
  31. data := context.Get(reflect.TypeOf(base.TmplData{})).Interface().(base.TmplData)
  32. validate(errors, data, f)
  33. }