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

session: handle user impersonation #461

Merged
merged 1 commit into from
Oct 17, 2023
Merged
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
11 changes: 7 additions & 4 deletions invenio_accounts/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,10 @@ def add_user_session(response):
session.regenerate()
# Save the session first so that the sid_s gets generated.
app.session_interface.save_session(app, session, response)
add_session(session)
current_accounts.datastore.commit()
# Don't add impersonation sessions
if "_impersonator_id" not in session:
add_session(session)
current_accounts.datastore.commit()
return response


Expand Down Expand Up @@ -130,8 +132,9 @@ def delete_session(sid_s):
# Remove entries from sessionstore
_sessionstore.delete(sid_s)
# Find and remove the corresponding SessionActivity entry
with db.session.begin_nested():
SessionActivity.query.filter_by(sid_s=sid_s).delete()
if "_impersonator_id" not in session:
with db.session.begin_nested():
SessionActivity.query.filter_by(sid_s=sid_s).delete()
return 1


Expand Down
Loading