User session tracking #93587

Merged
Oleg-Komarov merged 18 commits from user-session into main 2024-08-02 16:04:09 +02:00
3 changed files with 4 additions and 4 deletions
Showing only changes of commit 5177bf3b51 - Show all commits

View File

@ -38,7 +38,7 @@ def process_new_login(sender, request, user, **kwargs):
fields.update({"last_login_ip", "current_login_ip"}) fields.update({"last_login_ip", "current_login_ip"})
if user.has_confirmed_email: if user.has_confirmed_email:
Oleg-Komarov marked this conversation as resolved
Review

should be a call of a task

should be a call of a task
bid_main.tasks.send_new_user_session( bid_main.tasks.send_new_user_session_email(
user_pk=user.pk, user_pk=user.pk,
session_data={ session_data={
'device': str(user_session.device or 'Unknown'), 'device': str(user_session.device or 'Unknown'),

View File

@ -12,7 +12,7 @@ log = logging.getLogger(__name__)
@background(schedule={'action': TaskSchedule.RESCHEDULE_EXISTING}) @background(schedule={'action': TaskSchedule.RESCHEDULE_EXISTING})
def send_new_user_session(user_pk, session_data): def send_new_user_session_email(user_pk, session_data):
user = User.objects.get(pk=user_pk) user = User.objects.get(pk=user_pk)
log.info("sending a new user session email for account %s", user.pk) log.info("sending a new user session email for account %s", user.pk)

View File

@ -50,8 +50,8 @@ class TestActiveSessions(TestCase):
class TestNewUserSessionEmail(TestCase): class TestNewUserSessionEmail(TestCase):
@patch( @patch(
'bid_main.tasks.send_new_user_session', 'bid_main.tasks.send_new_user_session_email',
new=bid_main.tasks.send_new_user_session.task_function, new=bid_main.tasks.send_new_user_session_email.task_function,
) )
@patch( @patch(
'django.contrib.auth.base_user.AbstractBaseUser.check_password', 'django.contrib.auth.base_user.AbstractBaseUser.check_password',