-
Notifications
You must be signed in to change notification settings - Fork 80
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
Feat: Issue#80 PUT /user/additional_info api endpoints and test cases #81
Feat: Issue#80 PUT /user/additional_info api endpoints and test cases #81
Conversation
Update @ramitsawhney27 and @anitab-org/bridgeintech-maintainers . Here's the PUT /user/additional_info to update user's existing additional information. Can you please provide feedback? Thanks |
7daafbb
to
bacaf74
Compare
bacaf74
to
144c12e
Compare
Update @anitab-org/bridgeintech-maintainers . I've pushed the change requested on Timezone enum as our discussion last night. Now all logic on enum will be dealt by backend, frontend ui will only view enum value. |
3fe155a
to
cfcfa93
Compare
@anitab-org/bridgeintech-maintainers . This PR and all dependent PRs after this one have merge conflict that is caused by the recent merge from PR#77. I will leave the merge conflict in place (not going to solve it for now) until the next PR on the queue (PR#79) is merged. This way, the merge conflict serves as automatic blocker to this PR so we could prevent accidental merging of this PR before its depenceny/ies (blocker) PR/s get merged. 😉 |
@mtreacy002 can you solve this now, that #79 was merged? Ping me when you need my review |
cfcfa93
to
504b2c4
Compare
Update @isabelcosta and @anitab-org/bridgeintech-maintainers . I've solved the merge conflict. Can you please re-review this PR? Ta |
504b2c4
to
2b9d33a
Compare
Update @anitab-org/bridgeintech-maintainers . I've fix the user_id bug mentioned in my zulip post. Can you please re-review? Thanks |
app/api/request_api_utils.py
Outdated
@@ -36,6 +36,7 @@ def post_request(request_string, data): | |||
access_expiry_cookie = response_message.get("access_expiry") | |||
AUTH_COOKIE["Authorization"] = f"Bearer {access_token_cookie}" | |||
AUTH_COOKIE["Authorization"]["expires"] = access_expiry_cookie | |||
AUTH_COOKIE["user_id"] = 0 |
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.
why is this 0? @mtreacy002
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.
@isabelcosta. This is because if the server only just run for the first time, there'll be no AUTH_COOKIE["user_id"] ever initiated in the system. I tried once with if not AUTH_COOKIE["user_id"]
to check if it's none
but the system crash since there's no such attribute as user_id
in the AUTH_COOKIE. But if the system already has someone logged in, their "user_id" need to be cleared out so another logged in person not going to be accidentally associated to it. I also tried to set AUTH_COOKIE["user_id"] = None, but that didn't work as well (forgot what thee error message was).
So here, I used 0
as a default on AUTH_COOKIE["user_id"] since the database will never give an index of 0
as an ID to an instance (it always starts with 1). So, it's sort of the safest way to instantiate the attribute "user_id" for AUTH_COOKIE but without associating it to any user.
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 think we should keep it as None. We can look into the error, it would just be a TypeError, where you can cast None to 0 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.
Got it. I changed it to None and use catch the ValueError exception. Perhaps that crash I encountered last time was on something else then 😊
app/api/dao/user_extension.py
Outdated
""" | ||
|
||
user_id = int(AUTH_COOKIE["user_id"].value) | ||
if user_id == 0: |
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.
If not user_id
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.
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.
Very happy to see more usage of EAFP!
2b9d33a
to
5a792f6
Compare
Allow user to input Timezone in enum value Fix bug user id not retrieved Refactor reset user_id on login from 0 to None refactor user_extension dao with EAFP try catch
5a792f6
to
2b766fe
Compare
Update @ramitsawhney27 and @anitab-org/bridgeintech-maintainers . I've just pushed the requested changes. Can you please re-review? Thanks |
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 changes made in this PR were tested locally. Following are the results:
-
Code review - Done
-
All possible responses were tested as below:
-
OS Version: Windows 10
Description
Allow user to update their additional information.
Fixes #80
Type of Change:
Code/Quality Assurance Only
How Has This Been Tested?
Before update:
After update:
Success message on Swagger UI:
Checklist:
Code/Quality Assurance Only