You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
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