mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-03 09:43:33 +02:00
Retrieve domain invitations on first login
This commit is contained in:
parent
8338704315
commit
e54dda3ddd
4 changed files with 45 additions and 0 deletions
|
@ -1,6 +1,8 @@
|
|||
from django.contrib.auth.models import AbstractUser
|
||||
from django.db import models
|
||||
|
||||
from .domain_invitation import DomainInvitation
|
||||
|
||||
from phonenumber_field.modelfields import PhoneNumberField # type: ignore
|
||||
|
||||
|
||||
|
@ -31,3 +33,14 @@ class User(AbstractUser):
|
|||
return self.email
|
||||
else:
|
||||
return self.username
|
||||
|
||||
def first_login(self):
|
||||
"""Callback when the user is authenticated for the very first time.
|
||||
|
||||
When a user first arrives on the site, we need to retrieve any domain
|
||||
invitations that match their email address.
|
||||
"""
|
||||
for invitation in DomainInvitation.objects.filter(
|
||||
email=self.email, status=DomainInvitation.SENT
|
||||
):
|
||||
invitation.retrieve()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue