Skip to content

Commit cc71110

Browse files
committed
make send change primary email
1 parent 936a4e1 commit cc71110

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

api/users/serializers.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
from api.nodes.serializers import NodeSerializer, RegionRelationshipField
3535
from framework.auth.views import send_confirm_email_async
3636
from osf.exceptions import ValidationValueError, ValidationError, BlockedEmailError
37-
from osf.models import Email, Node, OSFUser, Preprint, Registration, UserMessage, Institution
37+
from osf.models import Email, Node, OSFUser, Preprint, Registration, UserMessage, Institution, NotificationType
3838
from osf.models.user_message import MessageTypes
3939
from osf.models.provider import AbstractProviderGroupObjectPermission
4040
from osf.utils.requests import string_type_request_headers
@@ -711,6 +711,17 @@ def update(self, instance, validated_data):
711711
if primary and instance.confirmed:
712712
user.username = instance.address
713713
user.save()
714+
notification_type = NotificationType.Type.USER_PRIMARY_EMAIL_CHANGED
715+
notification_type.instance.emit(
716+
subscribed_object=user,
717+
user=user,
718+
event_context={
719+
'user_fullname': user.fullname,
720+
'new_address': user.username,
721+
'can_change_preferences': False,
722+
'osf_contact_email': settings.OSF_CONTACT_EMAIL,
723+
}
724+
)
714725
elif primary and not instance.confirmed:
715726
raise exceptions.ValidationError('You cannot set an unconfirmed email address as your primary email address.')
716727

0 commit comments

Comments
 (0)