mirror of
https://github.com/simple-login/app.git
synced 2024-11-16 17:08:30 +01:00
35f6e67053
* feat: set up UserAuditLog * refactor: extract payment callbacks into their own files + handle subscription user_audit_log * feat: handle account linking for user audit log * chore: user_audit_log for mailboxes * chore: user_audit_log for custom domains * chore: user_audit_log for contacts * chore: user_audit_log for directories * fix: do not enforce cronjob being defined in choices + enable user deletion * chore: user_audit_log for user deletion * refactor: change emit_user_audit_log function to receive the full user object * feat: add user_audit_log migration * test: fix tests * test: add some tests for user_audit_log * fix: spf record verification user_audit_log * chore: add missing index to user_audit_log.created_at * chore: add missing index to alias_audit_log.created_at
44 lines
1.2 KiB
Python
44 lines
1.2 KiB
Python
from enum import Enum
|
|
|
|
from app.models import User, UserAuditLog
|
|
|
|
|
|
class UserAuditLogAction(Enum):
|
|
Upgrade = "upgrade"
|
|
SubscriptionExtended = "subscription_extended"
|
|
SubscriptionCancelled = "subscription_cancelled"
|
|
LinkAccount = "link_account"
|
|
UnlinkAccount = "unlink_account"
|
|
|
|
CreateMailbox = "create_mailbox"
|
|
VerifyMailbox = "verify_mailbox"
|
|
UpdateMailbox = "update_mailbox"
|
|
DeleteMailbox = "delete_mailbox"
|
|
|
|
CreateCustomDomain = "create_custom_domain"
|
|
VerifyCustomDomain = "verify_custom_domain"
|
|
UpdateCustomDomain = "update_custom_domain"
|
|
DeleteCustomDomain = "delete_custom_domain"
|
|
|
|
CreateContact = "create_contact"
|
|
UpdateContact = "update_contact"
|
|
DeleteContact = "delete_contact"
|
|
|
|
CreateDirectory = "create_directory"
|
|
UpdateDirectory = "update_directory"
|
|
DeleteDirectory = "delete_directory"
|
|
|
|
UserMarkedForDeletion = "user_marked_for_deletion"
|
|
DeleteUser = "delete_user"
|
|
|
|
|
|
def emit_user_audit_log(
|
|
user: User, action: UserAuditLogAction, message: str, commit: bool = False
|
|
):
|
|
UserAuditLog.create(
|
|
user_id=user.id,
|
|
user_email=user.email,
|
|
action=action.value,
|
|
message=message,
|
|
commit=commit,
|
|
)
|