mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	Move twofactor to models/login (#17143)
This commit is contained in:
		@@ -14,6 +14,7 @@ import (
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"code.gitea.io/gitea/models"
 | 
			
		||||
	"code.gitea.io/gitea/models/login"
 | 
			
		||||
	"code.gitea.io/gitea/modules/git"
 | 
			
		||||
	"code.gitea.io/gitea/modules/log"
 | 
			
		||||
	"code.gitea.io/gitea/modules/setting"
 | 
			
		||||
@@ -219,9 +220,9 @@ func (ctx *APIContext) CheckForOTP() {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	otpHeader := ctx.Req.Header.Get("X-Gitea-OTP")
 | 
			
		||||
	twofa, err := models.GetTwoFactorByUID(ctx.Context.User.ID)
 | 
			
		||||
	twofa, err := login.GetTwoFactorByUID(ctx.Context.User.ID)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		if models.IsErrTwoFactorNotEnrolled(err) {
 | 
			
		||||
		if login.IsErrTwoFactorNotEnrolled(err) {
 | 
			
		||||
			return // No 2FA enrollment for this user
 | 
			
		||||
		}
 | 
			
		||||
		ctx.Context.Error(http.StatusInternalServerError)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user