SIGN IN SIGN UP

feat: Add security model signals for User, Role, and Group CRUD operations (#2432)

* feat: Add security model signals for User, Role, and Group CRUD operations

* fix tests

* fix tests

* fix tests

* refactor: Use self.current_user instead of custom _get_current_user method

Simplify signal triggered_by by using the existing current_user property
from BaseSecurityManager instead of a redundant helper method.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix: Handle missing app/request context in signal emission

- Add app context check in _signals_enabled() to prevent errors during
  app initialization
- Add _get_triggered_by_user() helper to safely get current user,
  returning None when outside request context

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* test: Add coverage tests for security signals

Add tests for:
- SecurityModelChangeEvent properties (is_pre_commit, is_create, is_update, is_delete)
- Post-commit error handling (errors logged but not raised)
- _signals_enabled behavior outside app context
- _get_triggered_by_user returning None without request context

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix: Use mock for app context test to avoid CI issues

Mock has_app_context instead of relying on actual context teardown
which behaves differently in CI environment.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* Update tests/test_security_signals.py

Co-authored-by: Ville Brofeldt <33317356+villebro@users.noreply.github.com>

* Update tests/test_security_signals.py

Co-authored-by: Ville Brofeldt <33317356+villebro@users.noreply.github.com>

* fix: Correct assertIsEqual to assertEqual in test

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: Ville Brofeldt <33317356+villebro@users.noreply.github.com>
D
Daniel Vaz Gaspar committed
ca5bdfd562fe93eba287c968eb78ea17c41da4e1
Parent: b69c8f1
Committed by GitHub <noreply@github.com> on 2/23/2026, 8:32:24 AM