rusackas commented on code in PR #42934:
URL: https://github.com/apache/superset/pull/42934#discussion_r3802935716


##########
superset/security/session_invalidation.py:
##########
@@ -187,6 +198,23 @@ def _stamp_existing() -> int:
         _stamp_existing()
 
 
+def invalidate_sessions_for_user(user_id: int) -> None:
+    """Stamp the invalidation epoch for ``user_id`` from ordinary application 
code.
+
+    Convenience wrapper around ``invalidate_user_sessions`` for callers that
+    don't have the raw ``Connection`` the ``after_update`` event listener
+    receives -- e.g. a password-change flow. The stamp is written through the
+    current session's own connection, so it participates in whatever
+    transaction the caller's other pending changes belong to; it is not
+    committed here, so the caller's own commit (or the next flush that
+    triggers one) is what makes it durable.
+    """
+    # pylint: disable=import-outside-toplevel
+    from superset.extensions import db
+
+    invalidate_user_sessions(db.session.connection(), user_id)

Review Comment:
   It is covered, just not by name — 
`test_password_change_session_invalidation.py` exercises 
`invalidate_sessions_for_user` through its real callers 
(`security_manager.reset_password`, `CurrentUserRestApi.update_me`, the 
terminate-sessions admin action) against a real db session and asserts the 
epoch actually got stamped, which is closer to the real usage than a mock-based 
unit test would be.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to