fix(auth): an invite is the only way to an account
The README offered open registration, and the register handler still had a branch for a registration_settings mode nothing could set. Now every account after the first needs an invite; the first still needs the setup token from the log. Migration 0110 drops registration_settings and its queries, and backups no longer carry it (an older backup that holds it restores without it). The web form asks for the invite token as required. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,30 +0,0 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
// source: registration_settings.sql
|
||||
|
||||
package dbq
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
const getRegistrationMode = `-- name: GetRegistrationMode :one
|
||||
SELECT mode FROM registration_settings WHERE id = true
|
||||
`
|
||||
|
||||
func (q *Queries) GetRegistrationMode(ctx context.Context) (string, error) {
|
||||
row := q.db.QueryRow(ctx, getRegistrationMode)
|
||||
var mode string
|
||||
err := row.Scan(&mode)
|
||||
return mode, err
|
||||
}
|
||||
|
||||
const setRegistrationMode = `-- name: SetRegistrationMode :exec
|
||||
UPDATE registration_settings SET mode = $1 WHERE id = true
|
||||
`
|
||||
|
||||
func (q *Queries) SetRegistrationMode(ctx context.Context, mode string) error {
|
||||
_, err := q.db.Exec(ctx, setRegistrationMode, mode)
|
||||
return err
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
CREATE TABLE registration_settings (
|
||||
id boolean DEFAULT true NOT NULL PRIMARY KEY,
|
||||
mode text DEFAULT 'invite_only'::text NOT NULL,
|
||||
CONSTRAINT registration_settings_mode_check CHECK ((mode = ANY (ARRAY['invite_only'::text, 'open'::text]))),
|
||||
CONSTRAINT registration_settings_singleton CHECK ((id = true))
|
||||
);
|
||||
INSERT INTO registration_settings (id, mode) VALUES (true, 'invite_only');
|
||||
@@ -0,0 +1,4 @@
|
||||
-- An account needs an invite from an admin; the first account needs the
|
||||
-- setup token from the server log. There is no open registration, so the
|
||||
-- setting that would have chosen between the two is gone.
|
||||
DROP TABLE registration_settings;
|
||||
@@ -1,5 +0,0 @@
|
||||
-- name: GetRegistrationMode :one
|
||||
SELECT mode FROM registration_settings WHERE id = true;
|
||||
|
||||
-- name: SetRegistrationMode :exec
|
||||
UPDATE registration_settings SET mode = $1 WHERE id = true;
|
||||
Reference in New Issue
Block a user