aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'grumpy/utils.py')
-rw-r--r--grumpy/utils.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/grumpy/utils.py b/grumpy/utils.py
index 4891c3d..36bdd0a 100644
--- a/grumpy/utils.py
+++ b/grumpy/utils.py
@@ -7,7 +7,7 @@
:copyright: (c) 2010 Priit Laes
"""
-from flask import request, Response
+from flask import flash, g, redirect, request, url_for, Response
from functools import wraps
from smtplib import SMTP, SMTPException
@@ -31,6 +31,15 @@ def check_auth(username, password):
return username == app.config['TINDERBOX_USER'] and \
password == app.config['TINDERBOX_PASS']
+def requires_auth(f):
+ @wraps(f)
+ def decorated(*args, **kwargs):
+ if not g.user:
+ flash(u'This view requires valid user')
+ return redirect(url_for('index'))
+ return f(*args, **kwargs)
+ return decorated
+
def requires_auth_basic(f):
@wraps(f)
def decorated(*args, **kwargs):