Skip to content

Let a teacher's invitation code stand in for email verification - #752

Merged
mircealungu merged 1 commit into
masterfrom
auto-verify-cohort-signups
Sep 17, 2026
Merged

mircealungu merged 1 commit into
masterfrom
auto-verify-cohort-signups

Conversation

@mircealungu

@mircealungu mircealungu commented Sep 17, 2026

Copy link
Copy Markdown
Member

What

A signup whose invitation code resolves to a cohort is created with email_verified = True and is not sent a confirmation code. Signups without a code, or with a code that resolves to no cohort, are unchanged.

Why

The teacher who issued the code has already vouched for the student, and cohort_still_has_capacity() bounds the class size. Set against that, asking a class of thirty to each find a code in their mail costs a lesson — on school devices where some of them cannot reach their mail at all, and where a code may expire before they get home.

Sending "please confirm your email" to an account that is already verified would only send the student looking for a step that does not exist, so the mail is skipped for them too.

This is a convenience change. It is not a fix for the recent lockout at Cygnus Gymnasium — that was a web bug (zeeguu/web#1247), and the confirmation mails themselves were being delivered correctly throughout.

Design note

The flag is set from the resolved cohort object, not from invite_code being non-empty. valid_invite_code() accepts more than cohort codes, and only a resolved cohort carries a teacher's vouching. Both creation paths already look the cohort up, with a capacity check, before building the user.

The avatar's commit

db_session.commit() after db_session.add(user_avatar) is load-bearing. The avatar had been committed by the verification code's commit — the one that just became conditional — so without it the avatar is discarded at teardown for precisely the signups this change affects.

Tests

zeeguu/core/test/test_account_creation_verification.py, 5 cases: a cohort signup is verified and issues no code; the cohort match is case-insensitive; no invite code still verifies by email; a code resolving to no cohort still verifies by email; the avatar survives a cohort signup.

The avatar case rolls the session back before asserting — querying directly would autoflush and pass either way. Confirmed it fails when the commit is removed; the first version of it did not, and was worthless.

Full suite: 551 passed, 2 failed. Both failures are in test_scheduling.py (test_level_doesnt_go_back_to_lower_level, test_level_full_cycle) and reproduce on clean origin/master — pre-existing and unrelated.

Related

Class-code lifecycle (expiry / teacher-controlled enrolment) is being looked at separately and should land before or with this.

🤖 Generated with Claude Code

A student signing up with a cohort's invitation code has already been
vouched for by the teacher who handed that code out, and the cohort's
capacity bounds what the shortcut opens up. Making a class of thirty each
go and find a code in their mail costs a lesson, and the teacher's word
is the better signal anyway. So a signup that resolves to a cohort is
created verified, and gets no confirmation mail — telling someone who is
already verified to "please confirm your email" only sends them looking
for a step that isn't there.

Keyed on the resolved cohort rather than on invite_code being non-empty:
valid_invite_code also accepts the global INVITATION_CODES from config,
which belong to no class and carry nobody's vouching, so those still
verify by email.

The avatar needs its own commit now. It had been riding along on the
verification code's commit, which is the one that just became
conditional; without this it would be discarded at teardown for exactly
the cohort signups this change is meant to help.

Note this is a convenience, not a fix for the recent lockout — the
confirmation mails were being delivered fine (zeeguu/web#1247 is where
that bug actually was). It just spares a class the detour.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

ArchLens - No architecturally relevant changes to the existing views

@mircealungu
mircealungu merged commit e41d706 into master Sep 17, 2026
3 checks passed
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.

1 participant