-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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: API to delete given social auth record for user #36204
base: master
Are you sure you want to change the base?
Conversation
Thanks for the pull request, @kaustavb12! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. Where can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
03caa8d
to
f60ae39
Compare
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.
Perhaps this could be added as a delete verb for the existing UserViewV2
?
152dd91
to
0e8510a
Compare
@xitij2000 You are right. I have modified the PR to now add delete verb to existing |
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 the code generally looks good and is working fine, but there are a few changes I'd suggest.
- We don't need to return anything from delete.
- We can use single query instead of three here.
@@ -14,6 +14,7 @@ | |||
from rest_framework.test import APITestCase | |||
from social_django.models import UserSocialAuth | |||
|
|||
from common.djangoapps.student.models import 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.
This is an odd place to import the User model from. Please use get_user_model instead from django.contrib.auth import get_user_model
user = User.objects.get(**{identifier.kind: identifier.value}) | ||
social_auth_records = UserSocialAuth.objects.filter(user=user) | ||
social_auth_records.get(uid=uid).delete() |
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 it's better to condense this into a single query:
UserSocialAuth.objects.get(**{"user__"+identifier.kind: identifier.value}, uid=uid).delete()
Conventionally, delete doesn't return any data, so you can switch to a 204 status code and return an empty response.
Description
This PR introduces an API to delete a social auth record with provided UId for a given user.
This API is intended for server to server calls from third party system.
Testing instructions
https://<LMS_HOST>/admin/social_django/usersocialauth/
and create a new social auth record for any user.https://<LMS_HOST>/api/third_party_auth/v0/providers/modify_auth
with JWT access token from a staff/admin user. Here's a sample JSON request body:Deadline
"None" if there's no rush, or provide a specific date or event (and reason) if there is one.
Other information
Private Ref: BB-9477