-
-
Save dennismonsewicz/b8c6093da0a5682e05cd to your computer and use it in GitHub Desktop.
This file contains 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
blueprint = Blueprint('client', __name__, template_folder='templates') | |
@blueprint.before_request | |
def load_session_from_cookie(): | |
if request.endpoint != 'client.me': | |
try: | |
cookie = request.cookies.get(settings.COOKIE_NAME, None) | |
# if cookie does not exist, redirect to login url | |
if not cookie: | |
session.pop('accountId', None) | |
return redirect(settings.LOGIN_URL) | |
account = check_sso_cookie(cookie) | |
if 'accountId' in session: | |
return | |
elif 'accountId' in account: | |
session['accountId'] = account.get('accountId') | |
return | |
else: | |
session.pop('accountId', None) | |
return redirect(settings.LOGIN_URL) | |
except BadSignature: | |
session.pop('accountId', None) | |
return redirect(settings.LOGIN_URL) | |
@blueprint.route('/') | |
def home(): | |
session.permanent = True | |
return render_template('index.html') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment