Codes are stored as SHA-256 hashes and consumed with one conditional update, so concurrent use of the same code succeeds at most once. Refs #40 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
14 lines
420 B
SQL
14 lines
420 B
SQL
-- +goose Up
|
|
-- Like users, these rows belong to a person rather than an organization and
|
|
-- are not under row-level security.
|
|
CREATE TABLE recovery_codes (
|
|
user_id uuid NOT NULL REFERENCES users (id) ON DELETE CASCADE,
|
|
code_hash bytea NOT NULL,
|
|
used_at timestamptz,
|
|
created_at timestamptz NOT NULL DEFAULT now(),
|
|
PRIMARY KEY (user_id, code_hash)
|
|
);
|
|
|
|
-- +goose Down
|
|
DROP TABLE recovery_codes;
|