Skip to content

Commit

Permalink
Fix auth route with recent change to get_subscriber_by_fxa_uid
Browse files Browse the repository at this point in the history
  • Loading branch information
MelissaAutumn committed Jan 8, 2024
1 parent 3f10c3a commit 7dfff89
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions backend/src/appointment/routes/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,18 @@ def fxa_callback(
raise HTTPException(400, "Email mismatch.")

# Check if we have an existing fxa connection by profile's uid
external_connection = repo.get_subscriber_by_fxa_uid(db, profile['uid'])
fxa_subscriber = repo.get_subscriber_by_fxa_uid(db, profile['uid'])
# Also look up the subscriber (in case we have an existing account that's not tied to a given fxa account)
subscriber = repo.get_subscriber_by_email(db, email)

if not external_connection and not subscriber:
if not fxa_subscriber and not subscriber:
subscriber = repo.create_subscriber(db, schemas.SubscriberBase(
email=email,
username=email,
timezone=timezone,
))
elif not subscriber:
subscriber = external_connection.owner
subscriber = fxa_subscriber

external_connection_schema = schemas.ExternalConnection(
name=profile['email'],
Expand All @@ -135,7 +135,7 @@ def fxa_callback(
token=json.dumps(creds)
)

if not external_connection:
if not fxa_subscriber:
repo.create_subscriber_external_connection(db, external_connection_schema)
else:
repo.update_subscriber_external_connection_token(db, json.dumps(creds), subscriber.id, external_connection_schema.type, external_connection_schema.type_id)
Expand Down

0 comments on commit 7dfff89

Please sign in to comment.