aboutsummaryrefslogtreecommitdiffstats
path: root/services/forms/user_form_auth_openid.go
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2021-04-06 20:44:05 +0100
committerGitHub <noreply@github.com>2021-04-06 20:44:05 +0100
commitfa3895ce81ba64689fbf76b91d96963541547881 (patch)
treed7fe6c24429ccbb1d55b53441cefb34799dee993 /services/forms/user_form_auth_openid.go
parent8be2cc4fc72e7985640dabdddb06cf78169c1882 (diff)
downloadgitea-fa3895ce81ba64689fbf76b91d96963541547881.tar.gz
gitea-fa3895ce81ba64689fbf76b91d96963541547881.zip
Move modules/forms to services/forms (#15305)
Forms are dependent on models and therefore should be in services. This PR also removes the old auth. aliasing Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'services/forms/user_form_auth_openid.go')
-rw-r--r--services/forms/user_form_auth_openid.go51
1 files changed, 51 insertions, 0 deletions
diff --git a/services/forms/user_form_auth_openid.go b/services/forms/user_form_auth_openid.go
new file mode 100644
index 0000000000..b34f9dcc97
--- /dev/null
+++ b/services/forms/user_form_auth_openid.go
@@ -0,0 +1,51 @@
+// Copyright 2017 The Gitea Authors. All rights reserved.
+// Use of this source code is governed by a MIT-style
+// license that can be found in the LICENSE file.
+
+package forms
+
+import (
+ "net/http"
+
+ "code.gitea.io/gitea/modules/context"
+ "code.gitea.io/gitea/modules/web/middleware"
+ "gitea.com/go-chi/binding"
+)
+
+// SignInOpenIDForm form for signing in with OpenID
+type SignInOpenIDForm struct {
+ Openid string `binding:"Required;MaxSize(256)"`
+ Remember bool
+}
+
+// Validate validates the fields
+func (f *SignInOpenIDForm) Validate(req *http.Request, errs binding.Errors) binding.Errors {
+ ctx := context.GetContext(req)
+ return middleware.Validate(errs, ctx.Data, f, ctx.Locale)
+}
+
+// SignUpOpenIDForm form for signin up with OpenID
+type SignUpOpenIDForm struct {
+ UserName string `binding:"Required;AlphaDashDot;MaxSize(40)"`
+ Email string `binding:"Required;Email;MaxSize(254)"`
+ GRecaptchaResponse string `form:"g-recaptcha-response"`
+ HcaptchaResponse string `form:"h-captcha-response"`
+}
+
+// Validate validates the fields
+func (f *SignUpOpenIDForm) Validate(req *http.Request, errs binding.Errors) binding.Errors {
+ ctx := context.GetContext(req)
+ return middleware.Validate(errs, ctx.Data, f, ctx.Locale)
+}
+
+// ConnectOpenIDForm form for connecting an existing account to an OpenID URI
+type ConnectOpenIDForm struct {
+ UserName string `binding:"Required;MaxSize(254)"`
+ Password string `binding:"Required;MaxSize(255)"`
+}
+
+// Validate validates the fields
+func (f *ConnectOpenIDForm) Validate(req *http.Request, errs binding.Errors) binding.Errors {
+ ctx := context.GetContext(req)
+ return middleware.Validate(errs, ctx.Data, f, ctx.Locale)
+}