feat(accounts): add admin accounts and user preferences
Remove public registration, support administrator-managed accounts, and persist personal preferences. Refs #2 #5 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
25
backend/internal/models/account_errors_test.go
Normal file
25
backend/internal/models/account_errors_test.go
Normal file
@ -0,0 +1,25 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/lib/pq"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestDuplicateEmailError(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
err error
|
||||
want bool
|
||||
}{
|
||||
{nil, false}, {errors.New("secret database detail"), false},
|
||||
{&pq.Error{Code: "23505", Constraint: "users_email_key"}, true},
|
||||
{fmt.Errorf("insert: %w", &pq.Error{Code: "23505", Constraint: "users_email_key"}), true},
|
||||
{&pq.Error{Code: "23505", Constraint: "users_pkey"}, false},
|
||||
{&pq.Error{Code: "23514", Constraint: "users_email_key"}, false},
|
||||
} {
|
||||
if got := IsDuplicateEmail(tc.err); got != tc.want {
|
||||
t.Fatalf("got %v want %v", got, tc.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user