No description
  • Python 92.7%
  • HTML 6.3%
  • Mako 1%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-11-01 12:26:09 +01:00
src refactor: the framework resolves confirmemail's settings from the schema, and config.py reads no environment 2026-10-31 17:39:45 +01:00
.gitignore chore: bump version to v1.2.0 2026-03-25 12:25:57 +00:00
COPYING License under LGPL-3.0-or-later 2026-10-11 11:49:53 +02:00
COPYING.LESSER License under LGPL-3.0-or-later 2026-10-11 11:49:53 +02:00
MANIFEST.in feat: confirm by a button on a one-time link, never signing in or reopening an account 2026-10-23 22:48:12 +02:00
pyproject.toml chore: release splent_io/splent_feature_confirmemail to v2.4.0 2026-11-01 12:26:09 +01:00
README.md feat: confirmemail says when another account took the new address, and asks to try again when the database refuses (ID-15) 2026-10-25 04:30:55 +01:00

splent_feature_confirmemail

The confirmemail feature of a SPLENT product line.

It proves that an address belongs to its account. With it installed, an account opened by a sign-up waits until its owner follows the link mailed to the address (auth's AUTH_REQUIRE_VERIFIED_EMAIL, empty by default, reads its presence). It needs auth 1.23 or later, which owns the account and the one-time tokens the links are made of, and mail, which sends them.

  1. auth sends user-registered. Unless the address is confirmed already (a provider vouched for it: email_verified=True), a link goes to it. The link carries one of auth's one-time tokens: 32 random bytes, of which auth keeps the SHA-256, the account, the address it went to and its expiry (CONFIRM_EMAIL_TOKEN_MAX_AGE, a day).
  2. GET /confirm_user/<token> shows a page with a button and confirms nothing, so a mail scanner that opens every link changes nothing.
  3. The POST spends the token and, in the same transaction, marks the address confirmed and ends every session of the account. It signs nobody in, and an account an administrator switched off stays off.
Case Result
A link used, expired, of the old signed kind, or not a link at all 410, a page that says which and asks for a new link
The same link pressed twice at once One confirms, the other gets the 410 page
An address change whose address another account took meanwhile 410, a page that says the account kept its address
The database refuses the confirmation 503, the page again saying the link still works (errors.ConfirmationNotSaved); the driver's message goes to the log

The token pages send no Referer, are not cached and run no script of another site (auth's keep_token_private).

/confirmemail asks for an address and mails a new link when it belongs to an account waiting for one. The answer is the same either way. Logging in with the right password on an account that waits also mails a new link. An account gets one link per CONFIRM_EMAIL_RESEND_SECONDS (five minutes) however often it is asked for, and following any link spends the others.

Accounts carried over from an older site

An account auth knows was carried over from a site that never confirmed addresses (legacy_v2, User.is_legacy_unconfirmed) signs in unconfirmed. auth asks for its link at its first sign-in, through send_confirmation, and again from its /account/confirm-email page when the person asks. Its mail says it comes from the previous version of the site and what waits for the confirmation, instead of the sign-up's wording. The button confirms it as any other.

A new address

auth's My account asks for the current password to change the address and keeps the new one in pending_email. auth calls ConfirmemailService.send_email_change(user, old_email), which mails the new address a link to /confirm_email_change/<token> and tells the old address that someone asked to move the account. The account keeps signing in with its address until the link is followed. The button then moves it, marks the new address confirmed, ends every session, spends the links mailed to the old address and tells it the change was made.

Settings

Setting Default
CONFIRM_EMAIL_TOKEN_MAX_AGE 86400 Seconds a link works
CONFIRM_EMAIL_RESEND_SECONDS 300 Seconds between two links to one account

CONFIRM_EMAIL_SALT is no longer read: the links are not signed values.

Use it in a product

splent feature:add splent_feature_confirmemail