Add endpoint to quickly get the current user
This commit is contained in:
parent
b1d3fa0600
commit
9d8fa611b1
|
@ -105,6 +105,15 @@ async def get_users() -> list[UserData]:
|
|||
return [UserData.from_user(user) for user in users]
|
||||
|
||||
|
||||
@protected_router.get("/me")
|
||||
async def get_current_user(user: CurrentUserDep) -> UserData:
|
||||
"""Get the current user.
|
||||
|
||||
This endpoint can also be used to check if the user is authenticated.
|
||||
"""
|
||||
return UserData.from_user(user)
|
||||
|
||||
|
||||
@protected_router.get("/{user_id}")
|
||||
async def get_user(user_id: PydanticObjectId) -> UserData:
|
||||
"""Get a specific user."""
|
||||
|
|
Loading…
Reference in a new issue