Feat Auth: show sign-in codes and email links in the console in local development

Merged
ND
15d ago
+696-2

Closes #11568

This is a development aid. Until now, getting one of the codes or links below meant having a mail server configured and the app online, then waiting for the email. Most local setups have neither, so contributors could not finish these flows without reading the code from the database.

On a local development instance, the API now prints each of them on its console when it sends the email:

  • sign-in code and link
  • email verification code and link
  • password reset links, for one or several workspaces
  • invitation links: user, employee, team (with its code) and client
  • email change code
  • team join request code
  • account deletion link

A line looks like [DEV] Sign-in code for jane@example.com: 123456. It prints on a development build of the API (yarn start or yarn start:api) whose API_BASE_URL and CLIENT_BASE_URL are on localhost or a private network (10.x, 172.16-31.x, 192.168.x). The Docker images are production builds, so they print only with PRINT_EMAIL_CODES=true, NODE_ENV=development and both URLs on localhost. docker-compose.demo.yml sets it here, and ever-co/ever-teams#4886 sets it for docker compose up api.

Staging, production and the public demo print nothing, so the rule from #9506 of keeping codes out of the logs still holds there. The emails are sent exactly as before.