Skip to content

Backend to allow changing email during signup - #9627

Open
nc225 wants to merge 4 commits into
developfrom
backend/bugfix/signup-email-change-backend
Open

Backend to allow changing email during signup#9627
nc225 wants to merge 4 commits into
developfrom
backend/bugfix/signup-email-change-backend

Conversation

@nc225

@nc225 nc225 commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Implements the backend changes to close #9092. Frontend changes are here: #9626. This PR choose option 3 from this comment and lets users change their email at the email verification step. BE changes are necessary here because otherwise, when the user goes to make a new SignupFlow with their correct email address, the desired username is blocked by the old SignupFlow.

I tried to follow the path of our current "ChangeEmailV2" functions, which allow a logged-in user to change the account email address, but for changing signup emails I put the code in auth.py (with the other signup functions) instead of account.py where ChangeEmailV2 lives (with the other logged-in-user functions.) This new functionality also differs from ChangeEmailV2 in that passwords are not involved in changing signup emails, and we don't notify the old_email since it was never verified to begin with. Since we're changing the email in SignupFlow, this invalidates the old email_token and releases the old email to any future Signup

One question for reviewers: do we want to limit the number of times a SignupFlow can change its email address? That's not happening in the current PR but I think if we add another element to SignupFlow in auth.proto we can do that.

Testing

I added a few tests to test_auth.py to check the backend functionality added by this PR. To run the backend tests, I took the following steps:

First I merged the frontend and backend branches into a local branch, reviewers can run:

# Make sure you're in the Couchers repository
cd couchers
git fetch origin
git switch -c review/signup-email-change origin/develop
git merge --no-edit origin/backend/bugfix/signup-email-change-backend
git merge --no-edit origin/web/bugfix/signup-email-change-frontend

Then, a couple steps from the frontend guide: In one terminal, start the local backend:

## terminal 1
cd app
docker run --rm -w /app -v $(pwd):/app registry.gitlab.com/couchers/grpc ./generate_protos.sh
docker compose up

In a second terminal, start the local frontend:

## terminal 2
cd app/web
# use local development config
cp .env.localdev .env.development
# run the frontend (follow Quick Start for prep)
yarn start

To run the backend tests, I opened a third terminal and ran:

## terminal 3
cd app/backend
docker compose exec backend pytest src/tests/test_auth.py

Frontend tests are described in the other PR.

Backend checklist

  • Added tests for any new code or added a regression test if fixing a bug
  • Run the backend locally and it works
  • Added migrations if there are any database changes, rebased onto develop if necessary for linear migration history

Web frontend checklist

  • There are no console warnings when running the app
  • Added tests where relevant
  • Clicked around my changes running locally and it works
  • Checked Desktop, Mobile and Tablet screen sizes

For maintainers

  • Maintainers can push commits to my branch
  • Maintainers can merge this PR for me

@nc225
nc225 requested a review from aapeliv as a code owner August 25, 2026 18:17
@CouchersBot

CouchersBot commented Aug 25, 2026

Copy link
Copy Markdown
Member

Web (Vercel)

View the Vercel web preview for this branch.

Backend

Schema Schema diff Sample emails SQL query log
+3/-0 query shapes · 2 tests changed · 8 added, 0 removed

Other

Protos

url=urls.invite_code_link(code=request.code),
)

def SignupFlowChangeEmail(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

let's fold this into the existing signup rpc

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.

Frontend/signup: Can't change a bad email address

3 participants