stages/user_write: add signals

This commit is contained in:
Jens Langhammer
2020-07-07 15:46:57 +02:00
parent 6bc6f947dd
commit 17a2ac73e7
5 changed files with 24 additions and 8 deletions

View File

@ -4,8 +4,8 @@ from django.shortcuts import get_object_or_404
from passbook.flows.stage import StageView
from passbook.stages.invitation.models import Invitation, InvitationStage
from passbook.stages.prompt.stage import PLAN_CONTEXT_PROMPT
from passbook.stages.invitation.signals import invitation_used
from passbook.stages.prompt.stage import PLAN_CONTEXT_PROMPT
INVITATION_TOKEN_KEY = "token"
INVITATION_IN_EFFECT = "invitation_in_effect"

View File

@ -0,0 +1,4 @@
"""passbook user_write signals"""
from django.core.signals import Signal
user_write = Signal(providing_args=["request", "user", "data"])

View File

@ -12,6 +12,7 @@ from passbook.flows.stage import StageView
from passbook.lib.utils.reflection import class_to_path
from passbook.stages.password.stage import PLAN_CONTEXT_AUTHENTICATION_BACKEND
from passbook.stages.prompt.stage import PLAN_CONTEXT_PROMPT
from passbook.stages.user_write.signals import user_write
LOGGER = get_logger()
@ -49,6 +50,7 @@ class UserWriteStageView(StageView):
else:
user.attributes[key] = value
user.save()
user_write.send(sender=self, request=request, user=user, data=data)
# Check if the password has been updated, and update the session auth hash
if any(["password" in x for x in data.keys()]):
update_session_auth_hash(self.request, user)