From 793047097c8495dfb8421e9dbb72b7a8d289c359 Mon Sep 17 00:00:00 2001 From: Wenkai Yin Date: Tue, 19 Nov 2019 18:55:54 +0800 Subject: [PATCH] Abort with the pre-defined status code when handling XSRF error As the status codes(422 and 417) are set in the error map, abort with them directly to active the pre-defined error handlers Signed-off-by: Wenkai Yin --- context/context.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/context/context.go b/context/context.go index bbd58299..e1262018 100644 --- a/context/context.go +++ b/context/context.go @@ -169,11 +169,11 @@ func (ctx *Context) CheckXSRFCookie() bool { token = ctx.Request.Header.Get("X-Csrftoken") } if token == "" { - ctx.Abort(403, "'_xsrf' argument missing from POST") + ctx.Abort(422, "422") return false } if ctx._xsrfToken != token { - ctx.Abort(403, "XSRF cookie does not match POST argument") + ctx.Abort(417, "417") return false } return true