diff --git a/flask_simpleldap/__init__.py b/flask_simpleldap/__init__.py index 12f28b9..73ab24c 100644 --- a/flask_simpleldap/__init__.py +++ b/flask_simpleldap/__init__.py @@ -296,8 +296,12 @@ def login_required(func): @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