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

10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
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 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" binding:"Required"`
  17. Host string `form:"host" binding:"Required"`
  18. Port int `form:"port" binding:"Required"`
  19. BaseDN string `form:"base_dn" binding:"Required"`
  20. Attributes string `form:"attributes" binding:"Required"`
  21. Filter string `form:"filter" binding:"Required"`
  22. MsAdSA string `form:"ms_ad_sa" binding:"Required"`
  23. IsActived bool `form:"is_actived"`
  24. }
  25. func (f *AuthenticationForm) Name(field string) string {
  26. names := map[string]string{
  27. "AuthName": "Authentication's name",
  28. "Domain": "Domain name",
  29. "Host": "Host address",
  30. "Port": "Port Number",
  31. "BaseDN": "Base DN",
  32. "Attributes": "Search attributes",
  33. "Filter": "Search filter",
  34. "MsAdSA": "Ms Ad SA",
  35. }
  36. return names[field]
  37. }
  38. func (f *AuthenticationForm) Validate(errors *binding.BindingErrors, req *http.Request, context martini.Context) {
  39. data := context.Get(reflect.TypeOf(base.TmplData{})).Interface().(base.TmplData)
  40. validate(errors, data, f)
  41. }