Signals from UserRepository

The lback.repositories.user_repository.UserRepository handles all direct database interactions for User entities. This repository is designed to emit signals at crucial points in the user lifecycle (create, update, delete). These signals are invaluable for various purposes, including:

  • Auditing: Tracking changes to user accounts for security and compliance.

  • Notifications: Triggering emails (e.g., welcome emails, account updates) or other alerts.

  • Integrations: Synchronizing user data with external systems.

  • Custom Logic: Implementing bespoke actions before or after user data modifications.

Signal Name

Description

Arguments (kwargs)

user_pre_create

Emitted just before a new User instance is created and added to the database session. This allows for validation or modification of data before persistence.

sender (UserRepository): The repository instance.<br>``data`` (dict): The dictionary of data used to create the User (password is masked for security).<br>``session`` (Session): The SQLAlchemy session being used for the operation.

user_post_create

Emitted immediately after a new User instance has been successfully created and added to the database session (but not yet committed). Useful for post-creation actions like sending welcome emails.

sender (UserRepository): The repository instance.<br>``user`` (User): The newly created User instance.<br>``session`` (Session): The SQLAlchemy session being used for the operation.

user_pre_update

Emitted just before an existing User instance is updated with new data in the database session. This is ideal for pre-update validation or preparing audit trails.

sender (UserRepository): The repository instance.<br>``user`` (User): The User instance about to be updated.<br>``update_data`` (dict): The dictionary of data used for the update (password is masked for security).<br>``session`` (Session): The SQLAlchemy session being used for the operation.

user_post_update

Emitted immediately after an existing User instance has been successfully updated in the database session (but not yet committed). Useful for post-update notifications or cache invalidation.

sender (UserRepository): The repository instance.<br>``user`` (User): The updated User instance.<br>``session`` (Session): The SQLAlchemy session being used for the operation.

user_pre_delete

Emitted just before a User instance is marked for deletion in the database session. This can be used for final checks or archiving data.

sender (UserRepository): The repository instance.<br>``user`` (User): The User instance about to be deleted.<br>``session`` (Session): The SQLAlchemy session being used for the operation.

user_post_delete

Emitted immediately after a User instance has been successfully marked for deletion in the database session (but not yet committed). Useful for cleanup tasks or confirming deletion in external systems.

sender (UserRepository): The repository instance.<br>``user_id`` (int or str): The ID of the User that was marked for deletion.<br>``session`` (Session): The SQLAlchemy session being used for the operation.