-
Notifications
You must be signed in to change notification settings - Fork 26
enable user creation and editing #158
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
enable user creation and editing #158
Conversation
Codecov Report
@@ Coverage Diff @@
## master #158 +/- ##
==========================================
+ Coverage 92.10% 92.23% +0.12%
==========================================
Files 32 32
Lines 1774 1789 +15
==========================================
+ Hits 1634 1650 +16
+ Misses 140 139 -1
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
piccolo_api/crud/endpoints.py
Outdated
| self.table._validate_password(password=cleaned_data["password"]) | ||
| cleaned_data["password"] = self.table.hash_password( | ||
| cleaned_data["password"] | ||
| ) | ||
| model = self.pydantic_model(**cleaned_data) | ||
| user_row = self.table(**model.dict()) | ||
| await user_row.save().run() | ||
| return Response(status_code=200) |
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 see your idea. You might be able to do this instead:
user = await self.table.create_user(**model.dict())
json = dump_json({'id': user.id})
return CustomJSONResponse(json, status_code=201)It still validates the password and hashes it. Also, it returns the data in the same format as other tables.
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 works perfectly and is much simpler. Thanks.
|
@dantownsend I think we don't need this and this anymore. |
|
@sinisaos Yes, they can be removed - don't think they'll be used. |
|
@sinisaos I'm a bit confused why MyPy is failing in GitHub Actions. It works OK for me locally. Is it the same for you? |
|
The MyPy errors are when the latest version of fastapi is installed. |
|
@sinisaos Sorry for the delay on this - I thought we already merged it in. |
|
@dantownsend No worries. When you have time, look at the other PRs in Piccolo Api, and also in Piccolo Admin, where we have several stale PRs. |
Enabled user creation and editing in Piccolo Admin