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.

user_form_auth_openid.go 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // Copyright 2017 The Gitea 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 forms
  5. import (
  6. "net/http"
  7. "code.gitea.io/gitea/modules/context"
  8. "code.gitea.io/gitea/modules/web/middleware"
  9. "gitea.com/go-chi/binding"
  10. )
  11. // SignInOpenIDForm form for signing in with OpenID
  12. type SignInOpenIDForm struct {
  13. Openid string `binding:"Required;MaxSize(256)"`
  14. Remember bool
  15. }
  16. // Validate validates the fields
  17. func (f *SignInOpenIDForm) Validate(req *http.Request, errs binding.Errors) binding.Errors {
  18. ctx := context.GetContext(req)
  19. return middleware.Validate(errs, ctx.Data, f, ctx.Locale)
  20. }
  21. // SignUpOpenIDForm form for signin up with OpenID
  22. type SignUpOpenIDForm struct {
  23. UserName string `binding:"Required;AlphaDashDot;MaxSize(40)"`
  24. Email string `binding:"Required;Email;MaxSize(254)"`
  25. GRecaptchaResponse string `form:"g-recaptcha-response"`
  26. HcaptchaResponse string `form:"h-captcha-response"`
  27. }
  28. // Validate validates the fields
  29. func (f *SignUpOpenIDForm) Validate(req *http.Request, errs binding.Errors) binding.Errors {
  30. ctx := context.GetContext(req)
  31. return middleware.Validate(errs, ctx.Data, f, ctx.Locale)
  32. }
  33. // ConnectOpenIDForm form for connecting an existing account to an OpenID URI
  34. type ConnectOpenIDForm struct {
  35. UserName string `binding:"Required;MaxSize(254)"`
  36. Password string `binding:"Required;MaxSize(255)"`
  37. }
  38. // Validate validates the fields
  39. func (f *ConnectOpenIDForm) Validate(req *http.Request, errs binding.Errors) binding.Errors {
  40. ctx := context.GetContext(req)
  41. return middleware.Validate(errs, ctx.Data, f, ctx.Locale)
  42. }