feat(server/auth): Register 加 inviteCode + ReferralHook(注册后 best-effort 归因)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
wangjia
2026-07-13 07:33:42 +08:00
parent 2fb7391a17
commit 54d106ca8b
6 changed files with 83 additions and 26 deletions
+2 -2
View File
@@ -140,7 +140,7 @@ func TestIntegration_FullChain(t *testing.T) {
}
// 2. Register → trial subscription must exist for 7 days.
pair, apiErr := svc.Register(ctx, email, code, pw, "203.0.113.10", DeviceMeta{})
pair, apiErr := svc.Register(ctx, email, code, pw, "203.0.113.10", DeviceMeta{}, "")
if apiErr != nil {
t.Fatalf("Register: %v", apiErr)
}
@@ -170,7 +170,7 @@ func TestIntegration_FullChain(t *testing.T) {
}
// Force a fresh code regardless of rate limit.
_ = rdb.Set(ctx, codeKey(email), code, 10*time.Minute).Err()
if _, e := svc.Register(ctx, email, code, pw, "203.0.113.10", DeviceMeta{}); e == nil || e.Code != ErrCodeInvalid.Code {
if _, e := svc.Register(ctx, email, code, pw, "203.0.113.10", DeviceMeta{}, ""); e == nil || e.Code != ErrCodeInvalid.Code {
t.Fatalf("want code_invalid (anti-enumeration), got %v", e)
}