Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Add command to resend verification emails #694

Merged
merged 6 commits into from
May 17, 2022

Conversation

sarayourfriend
Copy link
Contributor

@sarayourfriend sarayourfriend commented May 11, 2022

Fixes

Fixes #689 by @AetherUnbound

Description

Adds a new command to run for resending verification emails. Note: I haven't written unit tests for this but I need to stop working on this for the day and come back to it tomorrow. Just wanted to get a draft up early.

Testing Instructions

I tried to write comprehensive unit tests. If you notice a missing branch please let me know so I can add additional tests.

You can test this on your local API (though I'm hoping the unit tests are sufficient) by setting the email backend to SMTP in your API settings without filling in the SMTP server information and then making some registration requests with multiple application names. Use a mix of the same email and different emails. This will cause the verifications to be completed, but because we haven't filled in the SMTP server information, it will fail to send the email (which is what was happening in production).

Then switch your settings back to the Console email backend and run the management command. You should see some helpful logs throughout the way, but also you'll see the emails that would be sent pop into the console. It will look like this:

Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: Verify your API credentials
From: 
To: [email protected]
Date: Thu, 12 May 2022 09:20:50 -0000
Message-ID: <165234725049.145.11337592980239670284@fa90ab837821>


The Openverse API OAuth2 email verification process has recently been fixed.
We have detected that you attempted to register an application using this email.

To verify your Openverse API credentials, click on the following link:

https://api.openverse.engineering//v1/auth_tokens/verify/<token redacted>

If you believe you received this message in error, please disregard it.

-------------------------------------------------------------------------------
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: Verify your API credentials
From: 
To: [email protected]
Date: Thu, 12 May 2022 09:20:50 -0000
Message-ID: <165234725049.145.2282716428617802226@fa90ab837821>


The Openverse API OAuth2 email verification process has recently been fixed.
We have detected that you attempted to register an application using this email.

To verify your Openverse API credentials, click on the following link:

https://api.openverse.engineering//v1/auth_tokens/verify/<token redacted>

If you believe you received this message in error, please disregard it.

-------------------------------------------------------------------------------
The following applications had email verifications sent.                                         

Application name: My amazing project
Cleaned related application count: 2
Cleaned related verification count: 0
Cleaned related registration count: 2


Application name: My amazing project5
Cleaned related application count: 0
Cleaned related verification count: 0
Cleaned related registration count: 0

To run the command:

For a dry run:

just dj resendoauthverification

For an actual run:

just dj resendoauthverification --no-dry_run

Note that the non-dry run requires you to input exactly YES as the response. Any other input including yes will not be accepted.

Checklist

  • My pull request has a descriptive title (not a vague title like Update index.md).
  • My pull request targets the default branch of the repository (main) or a parent feature branch.
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added or updated tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no visible errors.

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@openverse-bot openverse-bot added 💻 aspect: code Concerns the software code in the repository 🛠 goal: fix Bug fix 🟥 priority: critical Must be addressed ASAP labels May 11, 2022
@github-actions
Copy link

github-actions bot commented May 11, 2022

API Developer Docs Preview: Ready

https://wordpress.github.io/openverse-api/_preview/694

Please note that GitHub pages takes a little time to deploy newly pushed code, if the links above don't work or you see old versions, wait 5 minutes and try again.

You can check the GitHub pages deployment action list to see the current status of the deployments.

@sarayourfriend sarayourfriend marked this pull request as ready for review May 12, 2022 09:00
@sarayourfriend sarayourfriend requested a review from a team as a code owner May 12, 2022 09:00
@sarayourfriend sarayourfriend requested review from obulat and dhruvkb May 12, 2022 09:00
Copy link
Contributor

@AetherUnbound AetherUnbound left a comment

Choose a reason for hiding this comment

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

Love the thorough tests! My comments are only minor, thank you for jumping on this 📧


redis = get_redis_connection("default")

already_processed_emails = [
Copy link
Contributor

Choose a reason for hiding this comment

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

Fantastic idea using redis to save this!

@sarayourfriend sarayourfriend changed the title WIP - Add command to resend verification emails Add command to resend verification emails May 14, 2022
@sarayourfriend
Copy link
Contributor Author

I actually got a bit anxious about this branch and the unit tests I wrote. I'd like to write some additional tests that use mocked requests to the verification endpoint instead of factories to generate the test data... I just want to make totally sure that it's working 😁

@sarayourfriend sarayourfriend enabled auto-merge (squash) May 17, 2022 17:55
@sarayourfriend sarayourfriend merged commit 017b716 into main May 17, 2022
@sarayourfriend sarayourfriend deleted the add/verification-cleanup-command branch May 17, 2022 17:58
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
💻 aspect: code Concerns the software code in the repository 🛠 goal: fix Bug fix 🟥 priority: critical Must be addressed ASAP
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Command to re-send validation emails
4 participants