1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-03 09:07:19 +00:00

backport #6674 - API OTP Context (#6676)

This commit is contained in:
techknowlogick
2019-04-19 08:18:10 -04:00
committed by Lunny Xiao
parent 0acaa6bd00
commit ba12463175
4 changed files with 56 additions and 4 deletions

View File

@ -172,6 +172,10 @@ func reqToken() macaron.Handler {
if true == ctx.Data["IsApiToken"] {
return
}
if ctx.Context.IsBasicAuth {
ctx.CheckForOTP()
return
}
if ctx.IsSigned {
ctx.RequireCSRF()
return
@ -181,11 +185,12 @@ func reqToken() macaron.Handler {
}
func reqBasicAuth() macaron.Handler {
return func(ctx *context.Context) {
if !ctx.IsBasicAuth {
ctx.Error(401)
return func(ctx *context.APIContext) {
if !ctx.Context.IsBasicAuth {
ctx.Context.Error(401)
return
}
ctx.CheckForOTP()
}
}