mirror of
https://github.com/fastapi-users/fastapi-users.git
synced 2025-08-14 18:58:10 +08:00
Update verify.py (#1200)
* Update verify.py When using a schema setup as proposed in the documentation like: ReadUser, CreateUser, UpdateUser and BaseUser in the combination with MongoDB / Beanie, the verify() method will not "enforce" the `user_schema` but instead will return the `BaseUser` which will cause serialisation errors as such: ``` pydantic.error_wrappers.ValidationError: 1 validation error for ReadUser response -> id ``` because the mapping between MongoDBs internal `_id` and the Pydantic `id` does not work. * use `from_orm`
This commit is contained in:
@ -69,7 +69,8 @@ def get_verify_router(
|
||||
user_manager: BaseUserManager[models.UP, models.ID] = Depends(get_user_manager),
|
||||
):
|
||||
try:
|
||||
return await user_manager.verify(token, request)
|
||||
user = await user_manager.verify(token, request)
|
||||
return user_schema.from_orm(user)
|
||||
except (exceptions.InvalidVerifyToken, exceptions.UserNotExists):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_400_BAD_REQUEST,
|
||||
|
Reference in New Issue
Block a user