registration-service Service

Owns the registration transaction (consumer side of the invite_codes data row).

Function I/O

NameInOutSidePurpose
RegisterWithInvitectx, RegisterInputNewUserID | ErrInvalidCode | ErrEmailTakentxValidates code, hashes password, inserts user, consumes invite.
decideInviteValidrow, nowtrue | ErrInvalidCodepureChecks existence, expiry, consumption state.

Variables

NameTypeScopePurpose
inviteRowInviteCodeRowtxRow read with SELECT FOR UPDATE; gates the rest of the flow.
passwordHashstringtxbcrypt/argon2 hash of the submitted password; plaintext is discarded.

Internal data flow

1 Open transaction. 2 SELECT invite_codes FOR UPDATE WHERE code = ? 3 decideInviteValid against current time. 4 INSERT users row and UPDATE invite_codes.consumed_at. 5 Commit and return NewUserID.

Errors

NameWhenMeans
ErrInvalidCodeRow missing, expired, or already consumed.422 response with `invite_code` reason.
ErrEmailTakenUnique violation on users.email.422 response with `email` reason.