From 3f5b13a21ec4f029e9c7901be6ac1f3cba0f0e56 Mon Sep 17 00:00:00 2001
From: Braxton Robbason <braxton.robbason@gmail.com>
Date: Mon, 27 Jan 2020 17:40:49 -0500
Subject: [PATCH] Don't include /? in the next argument when user comes in to
 the index page

---
 flask_simpleldap/__init__.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/flask_simpleldap/__init__.py b/flask_simpleldap/__init__.py
index d8093d0..53fd48a 100644
--- a/flask_simpleldap/__init__.py
+++ b/flask_simpleldap/__init__.py
@@ -294,8 +294,12 @@ class LDAP(object):
         @wraps(func)
         def wrapped(*args, **kwargs):
             if g.user is None:
+                next_path=request.full_path or request.path
+                if next_path == '/?':
+                    return redirect(
+                        url_for(current_app.config['LDAP_LOGIN_VIEW']))
                 return redirect(url_for(current_app.config['LDAP_LOGIN_VIEW'],
-                                        next=request.full_path or request.path))
+                                        next=next_path))
             return func(*args, **kwargs)
 
         return wrapped
-- 
GitLab