Fix logic

This commit is contained in:
zandercymatics 2024-04-19 15:44:26 -06:00
parent 3e7f143a1e
commit a047380b59
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
2 changed files with 9 additions and 16 deletions

View file

@ -99,8 +99,11 @@ def login_callback(request):
return CLIENT.create_authn_request(request.session)
user = authenticate(request=request, **userinfo)
if user:
# Set the verification type
# Set the verification type if it doesn't already exist
if not user.verification_type:
user.set_user_verification_type()
user.save()
login(request, user)
logger.info("Successfully logged in user %s" % user)

View file

@ -168,20 +168,10 @@ class User(AbstractUser):
return verification_type
def set_user_verification_type(self):
if self.verification_type is None:
# Would need to check audit log
retrieved = DomainInvitation.DomainInvitationStatus.RETRIEVED
user_exists = self.existing_user(self.username)
verification_type = self.get_verification_type_from_email(self.email, invitation_status=retrieved)
# This should check if the type is unknown, use check_if_user_exists?
if verification_type == self.VerificationTypeChoices.REGULAR and not user_exists:
raise ValueError(f"No verification_type was found for {self} with id: {self.pk}")
else:
self.verification_type = verification_type
return self.verification_type
else:
return self.verification_type
def check_domain_invitations_on_login(self):
"""When a user first arrives on the site, we need to retrieve any domain