Fix auth
This commit is contained in:
@@ -1,14 +1,15 @@
|
||||
from fastapi import Depends, HTTPException, status
|
||||
from fastapi.security import OAuth2PasswordBearer
|
||||
from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials
|
||||
from firebase_admin import auth
|
||||
from .firebase_config import get_db
|
||||
|
||||
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="/auth/token")
|
||||
http_bearer_scheme = HTTPBearer()
|
||||
|
||||
async def get_current_user(token: str = Depends(oauth2_scheme)):
|
||||
async def get_current_user(credentials: HTTPAuthorizationCredentials = Depends(http_bearer_scheme)):
|
||||
"""
|
||||
Verifies the Firebase ID token and retrieves the user document from Firestore.
|
||||
"""
|
||||
token = credentials.credentials
|
||||
try:
|
||||
decoded_token = auth.verify_id_token(token)
|
||||
uid = decoded_token['uid']
|
||||
|
||||
Reference in New Issue
Block a user