1
0
Fork 0
forked from forgejo/forgejo

Revert "[BRANDING] X-Forgejo-OTP can be used instead of X-Gitea-OTP"

This reverts commit 9413fd0274.
This commit is contained in:
Earl Warren 2023-11-14 13:11:42 +01:00
parent d7e67cf616
commit a1e6944bd7
No known key found for this signature in database
GPG key ID: 0579CB2928A78A00
4 changed files with 4 additions and 34 deletions

View file

@ -197,20 +197,13 @@ func (ctx *APIContext) SetLinkHeader(total, pageSize int) {
}
}
func getOtpHeader(header http.Header) string {
otpHeader := header.Get("X-Gitea-OTP")
if forgejoHeader := header.Get("X-Forgejo-OTP"); forgejoHeader != "" {
otpHeader = forgejoHeader
}
return otpHeader
}
// CheckForOTP validates OTP
func (ctx *APIContext) CheckForOTP() {
if skip, ok := ctx.Data["SkipLocalTwoFA"]; ok && skip.(bool) {
return // Skip 2FA
}
otpHeader := ctx.Req.Header.Get("X-Gitea-OTP")
twofa, err := auth.GetTwoFactorByUID(ctx.Doer.ID)
if err != nil {
if auth.IsErrTwoFactorNotEnrolled(err) {
@ -219,7 +212,7 @@ func (ctx *APIContext) CheckForOTP() {
ctx.Error(http.StatusInternalServerError, "GetTwoFactorByUID", err)
return
}
ok, err := twofa.ValidateTOTP(getOtpHeader(ctx.Req.Header))
ok, err := twofa.ValidateTOTP(otpHeader)
if err != nil {
ctx.Error(http.StatusInternalServerError, "ValidateTOTP", err)
return