Skip to content

Commit

Permalink
put back user creation
Browse files Browse the repository at this point in the history
  • Loading branch information
willydouhard committed Apr 16, 2024
1 parent 83d2b87 commit 690d070
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions backend/chainlit/auth.py
Expand Up @@ -71,8 +71,17 @@ async def authenticate_user(token: str = Depends(reuseable_oauth)):
user = User(**dict)
except Exception as e:
raise HTTPException(status_code=401, detail="Invalid authentication token")

return user
if data_layer := get_data_layer():
try:
persisted_user = await data_layer.get_user(user.identifier)
if persisted_user == None:
persisted_user = await data_layer.create_user(user)
except Exception as e:
return user

return persisted_user
else:
return user


async def get_current_user(token: str = Depends(reuseable_oauth)):
Expand Down

0 comments on commit 690d070

Please sign in to comment.