From be646a74feb4e09e4dd2e9e0aed424c371d7e46d Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Mar 09 2016 22:13:30 +0000 Subject: Prevent the infinite loop of log-out/log-in If an user logs out, they are redirected to the page they were at, if that page requires log in, they are redirected to the login page and if they don't pay attention, they end-up at the point they started and logged in. This breaks this loop by recording when someone just logged out and breaking the redirect to the login page in this situation. --- diff --git a/pagure/__init__.py b/pagure/__init__.py index b23df05..53662a1 100644 --- a/pagure/__init__.py +++ b/pagure/__init__.py @@ -246,7 +246,9 @@ def login_required(function): @wraps(function) def decorated_function(*args, **kwargs): """ Decorated function, actually does the work. """ - if not authenticated(): + if flask.session.get('_justloggedout', False): + return flask.redirect(flask.url_for('.index')) + elif not authenticated(): return flask.redirect( flask.url_for('auth_login', next=flask.request.url)) elif auth_method == 'fas' and not flask.g.fas_user.cla_done: @@ -267,6 +269,10 @@ def inject_variables(): if authenticated(): forkbuttonform = pagure.forms.ConfirmationForm() + justlogedout = flask.session.get('_justloggedout', False) + if justlogedout: + flask.session['_justloggedout'] = None + return dict( version=__version__, admin=user_admin, @@ -346,6 +352,7 @@ def auth_logout(): # pragma: no cover elif APP.config.get('PAGURE_AUTH', None) == 'local': import pagure.ui.login as login login.logout() + flask.session['_justloggedout'] = True return flask.redirect(return_point)