Skip to content

Commit

Permalink
Preserve back param during the current session
Browse files Browse the repository at this point in the history
  • Loading branch information
kikkomep committed Oct 5, 2021
1 parent f2ef7cc commit 403175e
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions lifemonitor/auth/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import logging

import flask
from flask import flash, redirect, render_template, request, url_for
from flask import flash, redirect, render_template, request, session, url_for
from flask_login import login_required, login_user, logout_user
from lifemonitor.utils import (NextRouteRegistry, next_route_aware,
split_by_crlf, decodeBase64)
Expand Down Expand Up @@ -91,12 +91,15 @@ def index():
def profile(form=None, passwordForm=None, currentView=None, back=None):
currentView = currentView or request.args.get("currentView", 'accountsTab')
logger.debug(OpenApiSpecs.get_instance().authorization_code_scopes)
back_param = request.args.get('back', False)
try:
if back_param:
logger.debug("detected back param: %r", back_param)
except Exception as e:
logger.error("Unable to decode back param: %s", str(e))
back_param = request.args.get('back', None)
logger.debug("detected back param: %r", back_param)
if not current_user.is_authenticated:
session['lm_back_param'] = back_param
logger.debug("Pushing back param to session")
else:
logger.debug("Getting back param from session")
back_param = back_param or session.get('lm_back_param', False)
logger.debug("detected back param: %s", back_param)
return render_template("auth/profile.j2",
passwordForm=passwordForm or SetPasswordForm(),
oauth2ClientForm=form or Oauth2ClientForm(),
Expand Down

0 comments on commit 403175e

Please sign in to comment.