mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-16 01:27:03 +02:00
Check created at date for invited
This commit is contained in:
parent
2a7eb6db81
commit
2f494466fc
1 changed files with 22 additions and 1 deletions
|
@ -28,6 +28,13 @@ class User(AbstractUser):
|
||||||
"""
|
"""
|
||||||
Users achieve access to our system in a few different ways.
|
Users achieve access to our system in a few different ways.
|
||||||
These choices reflect those pathways.
|
These choices reflect those pathways.
|
||||||
|
|
||||||
|
Overview of verification types:
|
||||||
|
- GRANDFATHERED: User exists in the `TransitionDomain` table
|
||||||
|
- VERIFIED_BY_STAFF: User exists in the `VerifiedByStaff` table
|
||||||
|
- INVITED: User exists in the `DomainInvitation` table
|
||||||
|
- REGULAR: User was verified through IAL2
|
||||||
|
- FIXTURE_USER: User was created by fixtures
|
||||||
"""
|
"""
|
||||||
|
|
||||||
GRANDFATHERED = "grandfathered", "Legacy user"
|
GRANDFATHERED = "grandfathered", "Legacy user"
|
||||||
|
@ -146,9 +153,23 @@ class User(AbstractUser):
|
||||||
return needs_verification
|
return needs_verification
|
||||||
|
|
||||||
def set_user_verification_type(self):
|
def set_user_verification_type(self):
|
||||||
# Would need to check audit log
|
"""
|
||||||
|
Given pre-existing data from TransitionDomain, VerifiedByStaff, and DomainInvitation,
|
||||||
|
set the verification "type" defined in VerificationTypeChoices.
|
||||||
|
"""
|
||||||
retrieved = DomainInvitation.DomainInvitationStatus.RETRIEVED
|
retrieved = DomainInvitation.DomainInvitationStatus.RETRIEVED
|
||||||
verification_type = self.get_verification_type_from_email(self.email, invitation_status=retrieved)
|
verification_type = self.get_verification_type_from_email(self.email, invitation_status=retrieved)
|
||||||
|
|
||||||
|
# An existing user may have been invited to a domain after they got verified.
|
||||||
|
# We need to check for this condition.
|
||||||
|
if verification_type == User.VerificationTypeChoices.INVITED:
|
||||||
|
invitation = DomainInvitation.objects.filter(email=self.email, status=retrieved).order_by("created_at").first()
|
||||||
|
|
||||||
|
# If you joined BEFORE the oldest invitation was created, then you were verified normally.
|
||||||
|
# (See logic in get_verification_type_from_email)
|
||||||
|
if self.date_joined < invitation.created_at:
|
||||||
|
verification_type = User.VerificationTypeChoices.REGULAR
|
||||||
|
|
||||||
self.verification_type = verification_type
|
self.verification_type = verification_type
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue