Skip to content
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

fix: user delete social auth #3693

Merged

Conversation

shubham-padia
Copy link
Contributor

@shubham-padia shubham-padia commented Mar 28, 2024

Fixes #2782
Thanks for submitting a PR! Please check the boxes below:

  • I have run pre-commit to check linting
  • I have added information to docs/ if required so people know about the feature!
  • I have filled in the "Changes" section below?
  • I have filled in the "How did you test this code" section below?
  • I have used a Conventional Commit title for this Pull Request

Changes

We are enabling passwordless deletions only for Github and Google accounts and not for non email/password auth accounts, since it doesn't feel right to assume the behaviour of the next social auth that might be added. It's been a while since I dabbled with React, so please lmk if I should structure the code in a different way.

I'm also just ignoring the password field altogether for social auth as you can see in the API tests. Lmk if there are any concerns there.

How did you test this code?

Delete user with email/password:

email.account.delete.flagsmith.mp4

Delete user with social auth (only tested on google for now):

flagsmith.google.delete.mp4

Copy link

vercel bot commented Mar 28, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 17, 2024 5:17pm

Copy link

vercel bot commented Mar 28, 2024

@shubham-padia is attempting to deploy a commit to the Flagsmith Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions bot added front-end Issue related to the React Front End Dashboard api Issue related to the REST API labels Mar 28, 2024
@@ -126,6 +128,7 @@ class TheComponent extends Component {
render() {
const {
state: {
auth_type,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using snake case here, since first_name, last_name and similar fields are also doing the same for fields fetched from the API

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

{ isError: isMutationError, isSuccess: updateSuccess },
] = useDeleteAccountMutation()
const skipPasswordConfirmation =
auth_type === 'GOOGLE' || auth_type === 'GITHUB'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using string literals here, since I could not find enums being used elsewhere in the frontend codebase

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good.

Copy link
Contributor

github-actions bot commented Mar 28, 2024

Uffizzi Preview deployment-49078 was deleted.

@codecov-commenter
Copy link

codecov-commenter commented Mar 28, 2024

Codecov Report

Attention: Patch coverage is 80.00000% with 9 lines in your changes are missing coverage. Please review.

Project coverage is 95.89%. Comparing base (dd89326) to head (087e8d7).

Files Patch % Lines
api/custom_auth/serializers.py 43.75% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3693      +/-   ##
==========================================
- Coverage   95.92%   95.89%   -0.03%     
==========================================
  Files        1103     1103              
  Lines       34812    34848      +36     
==========================================
+ Hits        33392    33419      +27     
- Misses       1420     1429       +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@shubham-padia
Copy link
Contributor Author

Codecov Report

Attention: Patch coverage is 80.00000% with 9 lines in your changes are missing coverage. Please review.

Project coverage is 95.86%. Comparing base (87d2d52) to head (0277681).
Report is 1 commits behind head on main.

Files Patch % Lines
api/custom_auth/serializers.py 43.75% 9 Missing ⚠️
Additional details and impacted files
☔ View full report in Codecov by Sentry. 📢 Have feedback on the report? Share it here.

Not sure why all of these 9 lines of code are not being covered, they should be called by the testing functions 🤔 , except the fail message. I can add tests for the fail message, but not sure if it should be this PR or another one since it is related to the original PR introducing the delete user functionality.

https://app.codecov.io/gh/Flagsmith/flagsmith/commit/9bd0e3fba28f33d7c96b6d76c1fcf408e2474e78 (screenshot below)
Screenshot 2024-03-28 at 4 36 38 PM

@shubham-padia
Copy link
Contributor Author

bump for review

# create a couple of users
email1 = "test1@example.com"
email2 = "test2@example.com"
email3 = "test3@example.com"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please remove any unnecessary line breaks from the code?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shubham-padia are you able to resolve this and we can get this merged?

Copy link
Contributor

@novakzaballa novakzaballa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved, with a minor comment

@shubham-padia
Copy link
Contributor Author

@novakzaballa Replied to your comment. Let me know if there are any other blockers to getting this merged :) !

Fixes Flagsmith#2782.
We are enabling passwordless deletions only for Github
and Google accounts and not for non email/password auth
accounts, since it doesn't feel right to assume the behaviour
of the next social auth that might be added.
We are only checking the email match on the frontend,
because if user is directly using the API, we can assume they
know their stuff enough not to accidentally delete their
account. Social auth users with password will also get the email
confirmation screen.
@matthewelwell matthewelwell added this pull request to the merge queue Apr 29, 2024
Merged via the queue into Flagsmith:main with commit 3372207 Apr 29, 2024
22 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Issue related to the REST API front-end Issue related to the React Front End Dashboard
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow deletion of accounts that don't have password
4 participants