I have a web page generated by Flask that should show content depending on the status of a user.
At the moment, the relevant part of the jinja2 template looks like this:
{% if service.spotting_data.loco_id %}
Spotter Info *:<br />
{% if current_user.is_authenticated() %}
Loco: {{ service.spotting_data.loco_id }} <br />
Consist: {{ service.spotting_data.consist_info }}
{% else %}
We have information on the locomotive and consist for this service, however you need to <a href="{{ url_for('security.login') }}"> log in </a> to see it
{% endif %}
{% endif %}
The problem arises when someone clicks on the "log in" link - at the moment they just get redirected back to the index page and not the page that includes this template.
Is there any way to feed the <a href>
with an additional flag on the {{url_for()}}
to ensure that after log-in the user is redirected back to this page?