Replies: 1 comment
-
found out the answer is to just set 'optional' to True |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
in fastapi_users we do:
current_active_user = fastapi_users.current_user(active=True, verified=True)
and then have a dependency to make sure a user who is logged in is accessing the endpoint.
But is there any way to reverse it?
for example, we have this, that checks if user exists:
@router_orders.post("/cart/items/", response_model=CartItemResponse | MessageResponse)
async def add_cart_item(
item: CartItemCreateRequest,
test: bool = Query(False, description="If true, return example data."),
db: AsyncSession = Depends(get_db),
user: User = Depends(current_active_user),
):
but can we do something like:
@router_orders.post("/cart/items/", response_model=CartItemResponse | MessageResponse)
async def add_cart_item(
item: CartItemCreateRequest,
test: bool = Query(False, description="If true, return example data."),
db: AsyncSession = Depends(get_db),
unauthorized_user =NOT Depends(current_active_user),
):
?
Basically what I am trying to do is make sure users do not access the log in / register page once they are logged in.
Beta Was this translation helpful? Give feedback.
All reactions