feat(auth): persist preferred language per user and session

Refs #42

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
Sebastian UnterschützandClaude Opus 5.5 committed 2026-11-22 00:07:00 +01:00
1 parent 7dd1f87ffe
commit dde7b890b8
7 files changed
+60 -15

No files matched your search

+7 -7
View File
@@ -34,7 +34,7 @@ func TestSessionRoundTrip(t *testing.T) {
ctx := context.Background()
user, org := uuid.New(), uuid.New()
created, err := s.Create(ctx, user, org)
created, err := s.Create(ctx, user, org, "de")
if err != nil {
t.Fatal(err)
}
@@ -42,7 +42,7 @@ func TestSessionRoundTrip(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if got.UserID != user || got.OrgID != org || got.CSRF != created.CSRF {
if got.UserID != user || got.OrgID != org || got.Locale != "de" || got.CSRF != created.CSRF {
t.Fatalf("mismatch: %+v vs %+v", got, created)
}
if !got.CheckCSRF(created.CSRF) || got.CheckCSRF("") || got.CheckCSRF("x") {
@@ -59,7 +59,7 @@ func TestSessionRoundTrip(t *testing.T) {
func TestSessionAbsoluteLifetime(t *testing.T) {
s, now := testSessions(t)
ctx := context.Background()
sess, err := s.Create(ctx, uuid.New(), uuid.Nil)
sess, err := s.Create(ctx, uuid.New(), uuid.Nil, "")
if err != nil {
t.Fatal(err)
}
@@ -73,9 +73,9 @@ func TestDeleteAllForUser(t *testing.T) {
s, _ := testSessions(t)
ctx := context.Background()
user := uuid.New()
a, _ := s.Create(ctx, user, uuid.Nil)
b, _ := s.Create(ctx, user, uuid.Nil)
other, _ := s.Create(ctx, uuid.New(), uuid.Nil)
a, _ := s.Create(ctx, user, uuid.Nil, "")
b, _ := s.Create(ctx, user, uuid.Nil, "")
other, _ := s.Create(ctx, uuid.New(), uuid.Nil, "")
if err := s.DeleteAllForUser(ctx, user); err != nil {
t.Fatal(err)
@@ -93,7 +93,7 @@ func TestDeleteAllForUser(t *testing.T) {
func TestTokenNotStoredInPlain(t *testing.T) {
s, _ := testSessions(t)
ctx := context.Background()
sess, _ := s.Create(ctx, uuid.New(), uuid.Nil)
sess, _ := s.Create(ctx, uuid.New(), uuid.Nil, "")
if n, _ := s.rdb.Exists(ctx, "session:"+sess.Token).Result(); n != 0 {
t.Fatal("raw token used as redis key")
}