Skip to main content

find_fast_track_candidate

Function find_fast_track_candidate 

Source
pub async fn find_fast_track_candidate(
    conn: &mut PgConnection,
    primary_email: &str,
    sisu_person_id: &str,
) -> ModelResult<Option<FastTrackCandidate>>
Expand description

The one live account holding primary_email, with everything decide_fast_track needs. None when no account holds it, and also when more than one does — the fast track only ever acts on an unambiguous account, and ambiguity falls through to the mailed link like everything else.

Compares on lower(email), the same normalisation the users_email unique index uses, and no other: inventing address equivalences (Gmail dot-stripping, +tag folding) inside a security predicate is how one earns a CVE. sisu_person_id is only used to tell an earlier automatic link this account already rejected from someone else’s.

Locks the account row for the caller’s transaction, so a concurrent profile edit cannot change the address between reading the proof and writing the link that rests on it.