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
This commit is contained in:
parent
dae94e33be
commit
19ec2606e9
4 changed files with 56 additions and 4 deletions
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue