Email verification looks like a small feature until a worker retries at the same moment that a user clicks the link. Then the system has to answer some less small questions: which request owns the token, whether the message was already sent, and what a second click should do.
The first version usually look like this: create a token, send an email, and mark the account as verified when the token comes back. It works in a happy-path demo. In a service with timeouts, duplicate jobs, and multiple API instances, it can produce expired links, duplicate messages, or a verification endpoint that changes state twice.
This post describes a pattern I use for keeping email verification replay-safe. The email provider is only a delivery mechanism.…