Comments (1)
@LidorPrototype hi,
In the documentation it's saying:
FastAPI Users provides a dependency callable to easily inject authenticated user in your routes. They are available from your FastAPIUsers instance.
So you need to instantiate a FastAPIUsers object and derive current_users from this. Like this:
from fastapi_users import FastAPIUsers
...
fastapi_users = FastAPIUsers[User, PydanticObjectId](get_user_manager, [auth_backend])
current_active_user = fastapi_users.current_user(active=True)
after you can use this variable like this:
async def get_database_meta(database_id: PydanticObjectId, user: User = Depends(current_active_user)):
return await DatabaseMetadata.find_one(DatabaseMetadata.user == user.id, DatabaseMetadata.id == database_id)
I believe that the examples in the documentation are confusing for users because the variable fastapi_users
has the same name as the package.
from fastapi-users.
Related Issues (20)
- Why is the 'request' parameter not passed to 'user_manager.delete' in the 'delete' method of the router?
- Pylance/Pyright type error on full example in docs HOT 1
- Error in validation after new user (with relationship) registration
- TypeError: <class 'fastapi_users_db_beanie.BeanieBaseUser'> cannot be parametrized
- No docs for API user parameter
- Two different strategies generate the same tokens
- OAuthAccount.expires_at should be BigInteger HOT 1
- Support for Python 3.12 HOT 11
- The backend is not picked right with logout endpoint HOT 5
- How can i response many others user fields in jwt login ?
- fastapi depreciation in "full example" HOT 4
- Redis backends can't use 'reset-password' 'verify' HOT 4
- Inconsistency on responses HOT 2
- Crypt deprecation warning from passlib HOT 12
- user profile 401 Unauthorized HOT 3
- SQLAlchemyUserDatabase.create() got an unexpected keyword argument 'safe'
- forget password return null in responce body instead of token ?
- AttributeError: 'ValidatedEmail' object has no attribute 'normalized' HOT 2
- cannot import name 'BeanieUserDatabase' from 'fastapi_users.db'
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fastapi-users.