Skip to content

Commit

Permalink
security: filter out current session if it's set to None
Browse files Browse the repository at this point in the history
* also, rename it to avoid controversial terminology
  • Loading branch information
max-moser committed Sep 19, 2024
1 parent f39f60d commit db4d47b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions invenio_accounts/views/security.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,19 @@
def security():
"""View for security page."""
sessions = SessionActivity.query_by_user(user_id=current_user.get_id()).all()
master_session = None
current_session = None
for index, session in enumerate(sessions):
if SessionActivity.is_current(session.sid_s):
master_session = session
current_session = session
del sessions[index]

# If the current session is still `None`, filter it out
sessions = [current_session] + sessions if current_session is not None else sessions

return render_template(
current_app.config["ACCOUNTS_SETTINGS_SECURITY_TEMPLATE"],
formclass=RevokeForm,
sessions=[master_session] + sessions,
sessions=sessions,
is_current=SessionActivity.is_current,
)

Expand Down

0 comments on commit db4d47b

Please sign in to comment.