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:
18
backend/internal/models/preferences_test.go
Normal file
18
backend/internal/models/preferences_test.go
Normal file
@ -0,0 +1,18 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin/binding"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestPreferencesValidation(t *testing.T) {
|
||||
for _, language := range []string{"fr", "en", "de", "", "FR"} {
|
||||
for _, mode := range []string{"title", "title_content", "unknown", ""} {
|
||||
p := UserPreferences{Language: language, RankingMode: mode}
|
||||
wantValid := (language == "fr" || language == "en") && (mode == "title" || mode == "title_content")
|
||||
if err := binding.Validator.ValidateStruct(p); (err == nil) != wantValid {
|
||||
t.Fatalf("%+v: valid=%v error=%v", p, wantValid, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user