From de8a0a0635b722ae1f824b66b5674e58935617c5 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jan 31 2018 12:13:10 +0000 Subject: Reduce the number of calls to authenticated() in favor of flask.g This reduces a little bit the number of duplicated calls. Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/flask_app.py b/pagure/flask_app.py index 088bbfc..2891c87 100644 --- a/pagure/flask_app.py +++ b/pagure/flask_app.py @@ -240,9 +240,9 @@ def set_request(): flask.g.new_user = True flask.session['_new_user'] = False + flask.g.authenticated = pagure.utils.authenticated() flask.g.admin = pagure.utils.is_admin() - flask.g.authenticated = pagure.utils.authenticated() # Retrieve the variables in the URL args = flask.request.view_args or {} # Check if there is a `repo` and an `username` @@ -255,7 +255,7 @@ def set_request(): if repo: flask.g.repo = pagure.lib.get_authorized_project( flask.g.session, repo, user=username, namespace=namespace) - if pagure.utils.authenticated(): + if flask.g.authenticated: flask.g.repo_forked = pagure.lib.get_authorized_project( flask.g.session, repo, user=flask.g.fas_user.username, namespace=namespace) diff --git a/pagure/utils.py b/pagure/utils.py index f58057a..1485452 100644 --- a/pagure/utils.py +++ b/pagure/utils.py @@ -49,7 +49,7 @@ def is_safe_url(target): # pragma: no cover def is_admin(): """ Return whether the user is admin for this application or not. """ - if not authenticated(): + if not flask.g.authenticated: return False user = flask.g.fas_user