mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	Two factor authentication support (#630)
* Initial commit for 2FA support Signed-off-by: Andrew <write@imaginarycode.com> * Add vendored files * Add missing depends * A few clean ups * Added improvements, proper encryption * Better encryption key * Simplify "key" generation * Make 2FA enrollment page more robust * Fix typo * Rename twofa/2FA to TwoFactor * UNIQUE INDEX -> UNIQUE
This commit is contained in:
		@@ -173,3 +173,23 @@ type NewAccessTokenForm struct {
 | 
			
		||||
func (f *NewAccessTokenForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
 | 
			
		||||
	return validate(errs, ctx.Data, f, ctx.Locale)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// TwoFactorAuthForm for logging in with 2FA token.
 | 
			
		||||
type TwoFactorAuthForm struct {
 | 
			
		||||
	Passcode string `binding:"Required"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Validate valideates the fields
 | 
			
		||||
func (f *TwoFactorAuthForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
 | 
			
		||||
	return validate(errs, ctx.Data, f, ctx.Locale)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// TwoFactorScratchAuthForm for logging in with 2FA scratch token.
 | 
			
		||||
type TwoFactorScratchAuthForm struct {
 | 
			
		||||
	Token string `binding:"Required"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Validate valideates the fields
 | 
			
		||||
func (f *TwoFactorScratchAuthForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
 | 
			
		||||
	return validate(errs, ctx.Data, f, ctx.Locale)
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user