mirror of
https://github.com/simple-login/app.git
synced 2024-11-16 17:08:30 +01:00
373c30e53b
* Accounts to be scheduled to be deleted cannot receive emails or login * Create model and create migration for user * Add test for the cron function * Move logic to one place * Use the class name to call the static delete method
47 lines
1.1 KiB
Python
47 lines
1.1 KiB
Python
import newrelic.agent
|
|
|
|
from app.models import EnumE
|
|
|
|
|
|
class LoginEvent:
|
|
class ActionType(EnumE):
|
|
success = 0
|
|
failed = 1
|
|
disabled_login = 2
|
|
not_activated = 3
|
|
scheduled_to_be_deleted = 4
|
|
|
|
class Source(EnumE):
|
|
web = 0
|
|
api = 1
|
|
|
|
def __init__(self, action: ActionType, source: Source = Source.web):
|
|
self.action = action
|
|
self.source = source
|
|
|
|
def send(self):
|
|
newrelic.agent.record_custom_event(
|
|
"LoginEvent", {"action": self.action.name, "source": self.source.name}
|
|
)
|
|
|
|
|
|
class RegisterEvent:
|
|
class ActionType(EnumE):
|
|
success = 0
|
|
failed = 1
|
|
catpcha_failed = 2
|
|
email_in_use = 3
|
|
invalid_email = 4
|
|
|
|
class Source(EnumE):
|
|
web = 0
|
|
api = 1
|
|
|
|
def __init__(self, action: ActionType, source: Source = Source.web):
|
|
self.action = action
|
|
self.source = source
|
|
|
|
def send(self):
|
|
newrelic.agent.record_custom_event(
|
|
"RegisterEvent", {"action": self.action.name, "source": self.source.name}
|
|
)
|