Skip to content

Conversation

@shreyanshdwivedi
Copy link
Member

Fixes #5889

Checklist

  • I have read the Contribution & Best practices Guide and my PR follows them.
  • My branch is up-to-date with the Upstream development branch.
  • The unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • All the functions created/modified in this PR contain relevant docstrings.

Short description of what this resolves:

Currently, if a user deletes his/her account or the account is deleted by an admin, he/she can't signup with same email.

Changes proposed in this pull request:

  • Revamps the deletion of a user on server.
  • adds a function to add .deleted to a user's email which is to be deleted
  • removes .deleted from user's email which is to be restored.

@shreyanshdwivedi
Copy link
Member Author

@uds5501 @mrsaicharan1 @iamareebjamal everything is working fine but when I update the email of user in modify_email_for_user_to_be_restored function, it is not getting reflected on database. Can you please help me out with this?

if userEmail.endswith('.deleted'):
userEmail = userEmail[:-8]
else:
userEmail = userEmail + '.new'
Copy link
Member

Choose a reason for hiding this comment

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

Why?

Copy link
Member Author

Choose a reason for hiding this comment

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

Suppose a user is restored but he/she already signed up so the constraint is violated as 2 users cannot have same email. So I just added a '.new' to the email just for this sake.
This case however may happen only once or twice

Copy link
Member

Choose a reason for hiding this comment

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

This should not be automated. Admin should first change the email manually to something and then restore

Copy link
Member Author

Choose a reason for hiding this comment

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

@iamareebjamal I'll remove this condition and if you want I can open a separate issue to handle this.

when I update the email of user in modify_email_for_user_to_be_restored function, it is not getting reflected on database

In the meantime can you please give this a look? ^^

Copy link
Member Author

Choose a reason for hiding this comment

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

@iamareebjamal any help?

Copy link
Member

Choose a reason for hiding this comment

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

Will look tomorrow. @prateekj117 @uds5501 Can you please take a look as well?

Copy link
Contributor

Choose a reason for hiding this comment

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

@iamareebjamal @shreyanshdwivedi will take a look tonight

Copy link
Contributor

Choose a reason for hiding this comment

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

@shreyanshdwivedi The code looks correct. Any error logs during implementation?

Copy link
Member Author

Choose a reason for hiding this comment

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

No error logs. @uds5501
@iamareebjamal can you take a look as well please

@codecov
Copy link

codecov bot commented May 18, 2019

Codecov Report

Merging #5924 into development will decrease coverage by 0.1%.
The diff coverage is 20.93%.

Impacted file tree graph

@@               Coverage Diff               @@
##           development    #5924      +/-   ##
===============================================
- Coverage        66.48%   66.37%   -0.11%     
===============================================
  Files              286      287       +1     
  Lines            13933    13969      +36     
===============================================
+ Hits              9263     9272       +9     
- Misses            4670     4697      +27
Impacted Files Coverage Δ
app/api/helpers/user.py 25% <25%> (ø)
app/api/users.py 32.07% <9.09%> (-0.19%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 215b471...64675f1. Read the comment docs.

@codecov
Copy link

codecov bot commented May 18, 2019

Codecov Report

Merging #5924 into development will decrease coverage by 0.1%.
The diff coverage is 19.04%.

Impacted file tree graph

@@               Coverage Diff               @@
##           development    #5924      +/-   ##
===============================================
- Coverage        66.46%   66.35%   -0.11%     
===============================================
  Files              284      285       +1     
  Lines            13907    13941      +34     
===============================================
+ Hits              9243     9251       +8     
- Misses            4664     4690      +26
Impacted Files Coverage Δ
app/api/helpers/user.py 24.13% <24.13%> (ø)
app/api/users.py 31.87% <7.69%> (-0.39%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6d87e0e...892a5ed. Read the comment docs.

@fossasia fossasia deleted a comment May 18, 2019
@fossasia fossasia deleted a comment May 18, 2019
@fossasia fossasia deleted a comment May 18, 2019
@fossasia fossasia deleted a comment May 18, 2019
@fossasia fossasia deleted a comment May 18, 2019
@fossasia fossasia deleted a comment May 18, 2019
@shreyanshdwivedi shreyanshdwivedi force-pushed the deletedUser branch 3 times, most recently from 52a74da to fc2c4d8 Compare May 23, 2019 22:31
@shreyanshdwivedi
Copy link
Member Author

@iamareebjamal @uds5501 I've fixed the issue due to which the email was not getting restored while restoring the user. Also, I've added a migration file to update the email of past deleted users.
Please review

@shreyanshdwivedi shreyanshdwivedi changed the title [WIP] fix: allows deleted users to signup with same email fix: allows deleted users to signup with same email May 23, 2019
@auto-label auto-label bot added the fix label May 23, 2019
@shreyanshdwivedi
Copy link
Member Author

@iamareebjamal @CosmicCoder96 please review this :)

@shreyanshdwivedi
Copy link
Member Author

@iamareebjamal please take a look at the updated conditions and review the PR :)

@fossasia fossasia deleted a comment May 29, 2019
@fossasia fossasia deleted a comment May 29, 2019
@shreyanshdwivedi shreyanshdwivedi force-pushed the deletedUser branch 2 times, most recently from 4f105e6 to 143d995 Compare May 30, 2019 13:20
@shreyanshdwivedi
Copy link
Member Author

@iamareebjamal please review. I've updated the conditions

@shreyanshdwivedi
Copy link
Member Author

@iamareebjamal removed the duplicate error message. Please review

uds5501
uds5501 previously approved these changes Jun 3, 2019
Copy link
Contributor

@uds5501 uds5501 left a comment

Choose a reason for hiding this comment

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

This looks good 👍

"""
user_email = user.email
if user_email.endswith('.deleted'):
remove_str = '.deleted'
Copy link
Member

Choose a reason for hiding this comment

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

Move this statement a line above and replace '.deleted' with remove_str in if statement. That was the point of extracting it to a variable

@shreyanshdwivedi
Copy link
Member Author

@iamareebjamal updated the PR. Please review

iamareebjamal
iamareebjamal previously approved these changes Jun 3, 2019
@iamareebjamal
Copy link
Member

Build is failing

@shreyanshdwivedi
Copy link
Member Author

shreyanshdwivedi commented Jun 3, 2019

@iamareebjamal this is some random failure and I don't understand the cause 😅

error: Hooks handler process 'dredd-hooks-python ./tests/hook_main.py' exited with status: 1
warn: Hook handling timed out.
error: Hooks handler process 'dredd-hooks-python ./tests/hook_main.py' exited with status: 1
info: Backend server process exited
The command "dredd" failed and exited with 1 during .

@iamareebjamal
Copy link
Member

Multiple Migration Heads. Not a random error

@uds5501
Copy link
Contributor

uds5501 commented Jun 3, 2019

@shreyanshdwivedi It failed again. OH. kindly change the revises of your migration file to the current head. :)

fixed hound issues

updates the condition for restoring user

Adds migration file to update email of all deleted users

updates condition for modify_email_for_user_to_be_restored
@shreyanshdwivedi
Copy link
Member Author

@uds5501 yep. Was fixing that only 😅
Good to know the real cause of such errors. Thanks @iamareebjamal
Let's wait for the test to pass

@iamareebjamal
Copy link
Member

https://github.com/fossasia/open-event-server/blob/development/scripts/test_multiple_heads.sh is not working correctly. Open an issue

@shreyanshdwivedi
Copy link
Member Author

@iamareebjamal tests passed. Please merge

@iamareebjamal iamareebjamal merged commit a93e784 into fossasia:development Jun 3, 2019
@shreyanshdwivedi shreyanshdwivedi deleted the deletedUser branch June 14, 2019 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deleted user cannot signup with the same email

4 participants