Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

security: filter out master_session if it's set to None #492

Merged
merged 2 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
Changes
=======

Version 5.1.2 (released 2024-09-19)

- setup: bump minimum flask-security-invenio dependency
- security: handle missing value for current session

Version 5.1.1 (released 2024-08-08)

- revert: commit f9a8a85
Expand Down
2 changes: 1 addition & 1 deletion invenio_accounts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
from .ext import InvenioAccounts, InvenioAccountsREST, InvenioAccountsUI
from .proxies import current_accounts

__version__ = "5.1.1"
__version__ = "5.1.2"

__all__ = (
"__version__",
Expand Down
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