mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-15 09:07:02 +02:00
Fix logic
This commit is contained in:
parent
3e7f143a1e
commit
a047380b59
2 changed files with 9 additions and 16 deletions
|
@ -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)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue