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.

55 lines
1.7 KiB

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 AuthenticationForm struct {
  13. Id int64 `form:"id"`
  14. Type int `form:"type"`
  15. AuthName string `form:"name" binding:"Required;MaxSize(50)"`
  16. Domain string `form:"domain"`
  17. Host string `form:"host"`
  18. Port int `form:"port"`
  19. UseSSL bool `form:"usessl"`
  20. BaseDN string `form:"base_dn"`
  21. Attributes string `form:"attributes"`
  22. Filter string `form:"filter"`
  23. MsAdSA string `form:"ms_ad_sa"`
  24. IsActived bool `form:"is_actived"`
  25. SmtpAuth string `form:"smtpauth"`
  26. SmtpHost string `form:"smtphost"`
  27. SmtpPort int `form:"smtpport"`
  28. Tls bool `form:"tls"`
  29. AllowAutoRegister bool `form:"allowautoregister"`
  30. }
  31. func (f *AuthenticationForm) Name(field string) string {
  32. names := map[string]string{
  33. "AuthName": "Authentication's name",
  34. "Domain": "Domain name",
  35. "Host": "Host address",
  36. "Port": "Port Number",
  37. "UseSSL": "Use SSL",
  38. "BaseDN": "Base DN",
  39. "Attributes": "Search attributes",
  40. "Filter": "Search filter",
  41. "MsAdSA": "Ms Ad SA",
  42. }
  43. return names[field]
  44. }
  45. func (f *AuthenticationForm) Validate(errors *binding.Errors, req *http.Request, context martini.Context) {
  46. data := context.Get(reflect.TypeOf(base.TmplData{})).Interface().(base.TmplData)
  47. validate(errors, data, f)
  48. }