Replies: 2 comments
-
Im looking for the same solution. |
Beta Was this translation helpful? Give feedback.
0 replies
-
The thing is that current flag aren't just fields lookup, there is actually a complete logic involved behind them: fastapi-users/fastapi_users/authentication/authenticator.py Lines 174 to 186 in 1104460 If you need to add your own logic, you could very well define your own dependency: async def current_user_not_deleted(user: User = Depends(current_active_user)):
if user.is_deleted:
raise HTTPException(401)
return user |
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
-
In case you want to authenticate a user based on fields other than "is_active", "is_verified" and "is_superuser", it would be nice to be able to pass other field names as kwargs to current_user().
Example:
current_user = fastapi_users.current_user(is_deleted=False)
which authentcates user only if the value of "is_deleted" field is False for them.
Beta Was this translation helpful? Give feedback.
All reactions