8000 feat(preferences): added personal email verification by sroshc · Pull Request #1781 · tjcsl/ion · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat(preferences): added personal email verification #1781

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

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

sroshc
Copy link
Contributor
@sroshc sroshc commented May 7, 2025

Closes #1739

Proposed changes

  • Add UnverifiedEmail model with a foreign key to the email and a UUID field for the verification link.
  • Create a view (preferences/verify_email/<uuid>/) to verify the email and associated it with the user and unique UUID.
  • Add a verified boolean field to the Email model.
  • Prevent unverified emails from being set as the primary notification email.
  • Display unverified emails clearly in the preferences template to the user.
  • Send email verification asynchronously with a parametrized URL that verifies the associated email when clicked on.
  • The email verification works similarly to the implementation in mail forwarding

Brief description of rationale

When a user adds a new personal email in preferences, Ion should verify that they actually own the email. Ion should send a verification link containing a link, that, when clicked on, confirms the email ownership. This prevents users from adding addresses that are incorrect or that they do not own.

I have tested manually inputting the UUID in the url, and the logic does correctly verify the email. Also, it doesn't allow selecting non verified email as the primary notification email. The actual sending of the email should be tested extensively as I cannot test it in a development environment.

image
image
image

@sroshc sroshc requested a review from a team as a code owner May 7, 2025 02:27
@sroshc
Copy link
Contributor Author
sroshc commented May 7, 2025

Also, how are periodic celery tasks defined? I tried defining one programmatically to delete all expired unverified emails but no other tasks are seemed to be defined this way. I trying looking through the admin panel, but I still wasn't able to find where I could define a periodic celery-beat task.

@coveralls
Copy link
coveralls commented May 7, 2025

Coverage Status

coverage: 79.309% (-0.07%) from 79.382%
when pulling e6dd5a3 on sroshc:email
into 5fa3ea2 on tjcsl:dev.

@aarushtools
Copy link
Member

I think this is what you're looking for

CELERY_BEAT_SCHEDULE = {

@sroshc
Copy link
Contributor Author
sroshc commented May 7, 2025

Ah I see, thank you.

@sroshc sroshc force-pushed the email branch 3 times, most recently from c9824af to f9fa744 Compare May 8, 2025 15:14
@sroshc
Copy link
Contributor Author
sroshc commented May 9, 2025

@aarushtools is something like this what you had in mind?
I couldn't find any graphics like the one in the example in the static folders so I added a new one.
image

@aarushtools
Copy link
Member

yeah that looks good

@sroshc
Copy link
Contributor Author
sroshc commented May 10, 2025

Alright, I amended the commit with the new template

@sroshc sroshc requested a review from aarushtools May 17, 2025 14:57
Copy link
Member
@aarushtools aarushtools 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 really good! Just one thing:

The problem with using a celery task to delete unverified emails is that the links can stay active for longer than 12 hours. Since the celery task is set run at midnight, you could send an email out at 3 PM and it would be active for 9 hours before being cleared (instead of the expected 6 hours).

I suggest to see if the email link is supposed to be expired when the link is accessed in the verify_email_view, and if so, redirect to a page telling the user the link has expired (not Http404). Keep the celery task though just to make sure there isn't a buildup of links that were never clicked.
Also, can you make the max time to verify before the link expires 12 hours (in addition to making it a setting in settings/__init__.py).

@sroshc
Copy link
Contributor Author
sroshc commented May 18, 2025

Thanks for the review! I'll make a new template informing the user that a link is expired, not just throwing a 404 if it is.
I will also additionally make the verification time 12 hours and as a setting as well.

@alanzhu0
Copy link
Member
alanzhu0 commented May 19, 2025

Here's an idea for the verification page: I think it would be nice if it redirected to the preferences page, and then just sent a message saying "Your email has been verified, you can add it as a primary email now." (Django message in the bottom right) So then everything is in one place and we don't have to deal with making a new verified page.

@sroshc
Copy link
Contributor Author
sroshc commented May 19, 2025

That sounds good, it would be a lot cleaner. I'll work on it right now.

@sroshc sroshc force-pushed the email branch 3 times, most recently from 0c93630 to a1d0c30 Compare May 19, 2025 04:30
@sroshc
Copy link
Contributor Author
sroshc commented May 19, 2025

I made a mistake trying to resolve some conflicts, I'll try to have my changes finished sometimes this week.

@sroshc sroshc force-pushed the email branch 7 times, most recently from 27d56f1 to 7e57a17 Compare May 25, 2025 20:50
@sroshc
Copy link
Contributor Author
sroshc commented May 25, 2025

The amount of time it takes for an verification link to expire has been parameterized in settings.py. Also, instead of rendering a dedicated template, the verification link now redirects you to the preferences view with a Django message informing you if the email verification was successful or not.

@sroshc sroshc requested a review from aarushtools May 25, 2025 21:09
@alanzhu0
Copy link
Member

Aarush will review this, but another request: could you add this to the senior email forwarding (emailfwd) app?

@sroshc
Copy link
Contributor Author
sroshc commented May 31, 2025

Sure, I'll work on it this weekend.

@sroshc
Copy link
Contributor Author
sroshc commented Jun 2, 2025

I've worked on and given this implementation some thought, and I think the best approach to adding email verification to the senior emailfwd app would be to have the user select from the already verified email addresses in the preferences app. This way, we wouldn't have to duplicate the verification logic and keep all email verification centralized in a single app. I think this would make the system simpler and more maintainable.
What are your thoughts on this approach?

@alanzhu0
Copy link
Member
alanzhu0 commented Jun 2, 2025

Yes, that makes sense. So could you do the following then:

  • Change the current form for emailfwd to have a dropdown to select from the user's personal emails
  • Add text and a link on that page letting users know they have to add emails to to their settings
    Does that sound good?

@sroshc
Copy link
Contributor Author
sroshc commented Jun 2, 2025

Yes that all sounds good, I'll continue working on it.

@sroshc
Copy link
Contributor Author
sroshc commented Jun 3, 2025

Alright, the emailfwd app only accepts emails verified in the preferences app now.
Quick summary of my changes to emailfwd:

  • Made SeniorEmailForwardForm a drop down selector of all the user's verified emails
  • Updated template to inform user that only verified emails in user preferences can be set as a verification email
  • Updated old test cases and added new test case for clearing the email forward

@sroshc
Copy link
Contributor Author
sroshc commented Jun 13, 2025

@aarushtools Could you review this when you get the chance?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add personal email verification
4 participants
0