summaryrefslogtreecommitdiffstats
path: root/routers/api/v1/api.go
diff options
context:
space:
mode:
authortechknowlogick <matti@mdranta.net>2019-04-19 04:59:26 -0400
committerLauris BH <lauris@nix.lv>2019-04-19 11:59:26 +0300
commit19ec2606e91610421a3e9cd87c94748ef07ca468 (patch)
treec1898300efe5ad0bd2fa07ab3268d21804c6b5ed /routers/api/v1/api.go
parentdae94e33be52ca8749421165ee662d7f1300d115 (diff)
downloadgitea-19ec2606e91610421a3e9cd87c94748ef07ca468.tar.gz
gitea-19ec2606e91610421a3e9cd87c94748ef07ca468.zip
API OTP Context (#6674)
* API OTP Context * Update api.go * token * token * fix per discord * copyright header * remove check for token in OTP * Update auth.go * simplify * Update api.go
Diffstat (limited to 'routers/api/v1/api.go')
-rw-r--r--routers/api/v1/api.go11
1 files changed, 8 insertions, 3 deletions
diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go
index 8418ab94a1..ac92f7cd43 100644
--- a/routers/api/v1/api.go
+++ b/routers/api/v1/api.go
@@ -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()
}
}