Skip to content

Commit

Permalink
Merge branch 'main' into stage
Browse files Browse the repository at this point in the history
  • Loading branch information
MelissaAutumn committed Jan 9, 2024
2 parents 1dbaa81 + 7dfff89 commit 1f988d3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 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
2 changes: 0 additions & 2 deletions backend/src/appointment/routes/webhooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ def fxa_process(
logging.warning("Subscriber doesn't have refresh token.")
except requests.exceptions.HTTPError as ex:
logging.error(f"Error logging out user: {ex.response}")
logging.error(json.dumps(ex.request))
logging.error(json.dumps(ex.response))
case 'https://schemas.accounts.firefox.com/event/profile-change':
if event_data.get('email') is not None:
# Update the subscriber's email (and username for now)
Expand Down

0 comments on commit 1f988d3

Please sign in to comment.