Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integrate
fastapi-users
for user management #377Integrate
fastapi-users
for user management #377Changes from all commits
a4092e9
018157c
2239da5
aade3cb
b53127e
5f4d261
5aca0dc
a72b8fd
87eaddd
e91df8b
bbd0390
766e406
e40c882
49e20de
cb1c7b5
0450034
887441d
be9916b
8836489
ee67577
56a429f
46557c5
c9dde29
77a7b89
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
Check warning on line 24 in api/admin.py
GitHub Actions / Lint
Check warning on line 24 in api/admin.py
GitHub Actions / Lint
Check warning on line 32 in api/admin.py
GitHub Actions / Lint
Check warning on line 32 in api/admin.py
GitHub Actions / Lint
Check warning on line 55 in api/admin.py
GitHub Actions / Lint
Check warning on line 55 in api/admin.py
GitHub Actions / Lint
Check warning on line 56 in api/admin.py
GitHub Actions / Lint
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need Beanie here. I'll dig a bit deeper, as far as I know we don't actually use Beanie anywhere in the API code at the moment, just fastapi-users uses it internally.
We might however decide to rely more on Beanie going forward to simplify the code, it could basically be a replacement for the
Database
class somehow. See also the documentation:https://beanie-odm.dev/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are accessing DB to create an admin user with
db.create
. Also, access DB for finding existing users with the providedusername
indb.find_one_by_attributes
.For these methods to work, we need to initialize Beanie first as they are accessing the collection
user
created by Beanie.Check warning on line 59 in api/admin.py
GitHub Actions / Lint
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this should instead be in the
Authentication
class which would then depend onDatabase
to pass the instance. Again, let's first make sure this implementation works and then we can think of things to rework if needed.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method is specific to DB-related initialization. Hence, I added it to the
Database
class.Yes, we can refactore it later if required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I mean is that the
Database
class doesn't need thefastapi-users
initialisation, the dependency is the other way round. TheAuthentication
class usesfastapi-users
and as such it depends onDatabase
. At least that's my understanding. But like I wrote, I think it's not a blocker here and this PR is large enough so let's try and have it merged based on functionality from a user point of view and see if any follow-up reworks should be done.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The commit message for fixing the staging bug doesn't explain what this does. It looks like it's temporary so should it really be merged? This looks like a staging configuration issue, or maybe the API code should be able to deal with such cases and not try to send emails when the sender is not valid.
Check warning on line 27 in api/email_sender.py
GitHub Actions / Lint