Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

passwords: also verify email when resetting passwords#46307

Merged
bobheadxi merged 2 commits intomainfrom
reset-password-also-verifies-emails
Jan 11, 2023
Merged

passwords: also verify email when resetting passwords#46307
bobheadxi merged 2 commits intomainfrom
reset-password-also-verifies-emails

Conversation

@bobheadxi
Copy link
Member

With this change, when setting and resetting passwords, if the primary email is not verified the emailed link (not the copy-paste-able one) will now also verify the email when a user resets their password.

Addresses https://github.com/sourcegraph/sourcegraph/pull/46187#issuecomment-1373337503 as part of https://github.com/sourcegraph/customer/issues/1790.

Test plan

  1. sg start with SMTP configuration
  2. Create account
  3. User settings -> emails -> mark as unverified
  4. Site admin -> users -> send reset
  5. Click reset URL in email (not the copy-pasted one)
  6. Rest password and log in
  7. Email is now verified!

@bobheadxi bobheadxi requested review from a team and unknwon January 11, 2023 01:48
@cla-bot cla-bot bot added the cla-signed label Jan 11, 2023
@sg-e2e-regression-test-bob

Bundle size report 📦

Initial size Total size Async size Modules
0.00% (0.00 kb) 0.00% (+0.13 kb) 0.00% (+0.13 kb) 0.00% (0)

Look at the Statoscope report for a full comparison between the commits f26ecc5 and b897993 or learn more.

Open explanation
  • Initial size is the size of the initial bundle (the one that is loaded when you open the page)
  • Total size is the size of the initial bundle + all the async loaded chunks
  • Async size is the size of all the async loaded chunks
  • Modules is the number of modules in the initial bundle

@bobheadxi bobheadxi merged commit 18911c0 into main Jan 11, 2023
@bobheadxi bobheadxi deleted the reset-password-also-verifies-emails branch January 11, 2023 18:01
bobheadxi referenced this pull request Jan 25, 2023
Today, users created with `mutation { createUser }` automatically have their emails marked as verified, even if the email is bogus. This could cause us to automatically send potentially large numbers of emails automatically to nonexistent email addresses (see sourcegraph/customer#1790). To mitigate this, this change marks the emails of created users as unverified if SMTP is configured.

This has implications for Cloud instances, where `mutation { createUser }` is frequently used to create initial admin users. After this change, these users may receive a more limited set of emails (i.e. https://github.com/sourcegraph/sourcegraph/pull/46184) and have limited capabilities (i.e. unable to link account via external service) until they verify their email by:

1. using a "set password" or "reset password" link delivered by email (https://github.com/sourcegraph/sourcegraph/pull/46307)
1. using "verify email" in user settings to send an email verification
3. a site admin verifying the user email manually via `setUserEmailVerified` mutation or UI

## Test plan

<!-- All pull requests REQUIRE a test plan: https://docs.sourcegraph.com/dev/background-information/testing_principles -->

I've added new unit tests that cover the old and new set password behaviour on the mutation.

Manual test:

1. `sg start`, configured with SMTP in `dev-private`
2. Site admin -> users -> create `testuser` with email 
3. Site admin -> users -> `testuser` -> emails -> primary email is unverified
4. Log out
5. CLick password reset link in email
6. Log in
7. User -> emails -> primary email is verified

Co-authored-by: Joe Chen <joe@sourcegraph.com>
Co-authored-by: Milan Freml <kopancek@users.noreply.github.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants