From 60e5380d375395080af85b2cbe6858cdf45cd1f9 Mon Sep 17 00:00:00 2001 From: Markus Hauschild Date: Thu, 1 Oct 2015 16:39:19 +0200 Subject: [PATCH] Refactor isLoggedin. --- index.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/index.py b/index.py index 5dbce8f..cd9a798 100755 --- a/index.py +++ b/index.py @@ -32,10 +32,14 @@ class LoginForm(Form): submit = SubmitField('Login') +def isLoggedin(): + return 'uuid' in session and rdb.exists(session['uuid']) + + @app.route('/') def index(): nav = None - if 'uuid' in session and rdb.exists(session['uuid']): + if isLoggedin(): nav = ['edit', 'logout'] else: nav = ['login'] @@ -45,7 +49,7 @@ def index(): @app.route('/edit', methods=['GET', 'POST']) def edit(): - if 'uuid' not in session or not rdb.exists(session['uuid']): + if not isLoggedin(): return redirect(url_for('index')) nav = ['edit', 'logout']