Created
October 5, 2017 17:40
-
-
Save akkefa/9463fb2a6f41abaac123a102c0d1172d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functools import wraps | |
from flask import session, request, redirect, url_for | |
def login_required(f): | |
@wraps(f) | |
def decorated_function(*args, **kwargs): | |
if session.get("username") is None: | |
return redirect(url_for("user_app.login", next=request.url)) | |
return f(*args, **kwargs) | |
return decorated_function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment