From 6da26f6dda32f42aa44cce9a809e4689fb3d2f71 Mon Sep 17 00:00:00 2001 From: Zak Cutner Date: Fri, 5 Apr 2019 18:53:04 +0100 Subject: [PATCH] Prevent error when visiting "/_oauth" without state Before, if the user was already authenticated, visiting "/_oauth" without a "state" parameter would cause an exception. Automatically redirect to the route instead if the state parameter is not set. --- access.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/access.lua b/access.lua index 0452e85..bfafa9f 100644 --- a/access.lua +++ b/access.lua @@ -257,5 +257,9 @@ end -- if already authenticated, but still receives a /_oauth request, redirect to the correct destination if uri == "/_oauth" then - return ngx.redirect(uri_args["state"]) + if uri_args["state"] then + return ngx.redirect(uri_args["state"]) + else + return ngx.redirect("/") + end end