Skip to content

Commit

Permalink
Track Sentry users by internal id for now.
Browse files Browse the repository at this point in the history
  • Loading branch information
MelissaAutumn authored and jdbass committed May 17, 2024
1 parent 4c9b59c commit 4ae6783
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion backend/src/appointment/dependencies/auth.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
from typing import Annotated

import sentry_sdk
from fastapi import Depends, Request, HTTPException, Body
from fastapi.security import OAuth2PasswordBearer
import jwt
Expand Down Expand Up @@ -43,15 +44,21 @@ def get_subscriber(
token: Annotated[str, Depends(oauth2_scheme)],
db: Session = Depends(get_db),
):
"""Automatically retrieve and return the subscriber"""
if token is None:
raise InvalidTokenException()

"""Automatically retrieve and return the subscriber"""
user = get_user_from_token(db, token)

if user is None:
raise InvalidTokenException()

# Associate user id with users
if os.getenv('SENTRY_DSN'):
sentry_sdk.set_user({
'id': user.id,
})

return user


Expand Down

0 comments on commit 4ae6783

Please sign in to comment.