mirror of
				https://github.com/go-gitea/gitea
				synced 2025-11-04 05:18:25 +00:00 
			
		
		
		
	Enable this to require captcha validation for user login. You also must enable `ENABLE_CAPTCHA`. Summary: - Consolidate CAPTCHA template - add CAPTCHA handle and context - add `REQUIRE_CAPTCHA_FOR_LOGIN` config and docs - Consolidate CAPTCHA set-up and verification code Partially resolved #6049 Signed-off-by: Xinyu Zhou <i@sourcehut.net> Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: Andrew Thornton <art27@cantab.net>
		
			
				
	
	
		
			51 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			51 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
// 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;Username;MaxSize(40)"`
 | 
						|
	Email    string `binding:"Required;Email;MaxSize(254)"`
 | 
						|
}
 | 
						|
 | 
						|
// 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)
 | 
						|
}
 |