From c4355ac2363f10cb185f141d032b6b3c42429761 Mon Sep 17 00:00:00 2001 From: richjohnrambo Date: Wed, 23 Sep 2026 11:33:16 +0800 Subject: [PATCH] fix: accept raw phone secret for personal registration --- server/user.go | 6 +++++- server/user_registration_test.go | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/server/user.go b/server/user.go index a88a66b..ebbb2d0 100644 --- a/server/user.go +++ b/server/user.go @@ -50,7 +50,11 @@ func replyCreateUser(s *Session, msg *ClientComMessage, rec *auth.Rec) { } account, phone, secretAccount, phoneRegistration, err := resolveRegistrationAccount(msg.Acc.Username, msg.Acc.Phone) - if err != nil || !registrationSecretMatches(msg.Acc.Secret, secretAccount) { + secretMatches := registrationSecretMatches(msg.Acc.Secret, secretAccount) + if !secretMatches && phoneRegistration && account != secretAccount { + secretMatches = registrationSecretMatches(msg.Acc.Secret, strings.TrimSpace(msg.Acc.Phone)) + } + if err != nil || !secretMatches { logs.Warn.Println("create user: invalid registration account fields, sid=", s.sid) s.queueOut(decodeStoreError(types.ErrPolicy, msg.Id, msg.Timestamp, map[string]any{"what": "account", "reason": "REGISTRATION_ACCOUNT_INVALID"})) diff --git a/server/user_registration_test.go b/server/user_registration_test.go index 1613792..c9a448a 100644 --- a/server/user_registration_test.go +++ b/server/user_registration_test.go @@ -84,6 +84,9 @@ func TestRegistrationSecretForAccount(t *testing.T) { if got := string(registrationSecretForAccount([]byte("+8613800138000:secret"), "abcxyz123456")); got != "abcxyz123456:secret" { t.Fatalf("got %q", got) } + if got := string(registrationSecretForAccount([]byte("13800138000:secret"), "abcxyz123456")); got != "abcxyz123456:secret" { + t.Fatalf("got %q", got) + } } func TestValidateAccountRegistrationTenantDefaultsEnterpriseFromSession(t *testing.T) {