fix: accept raw phone secret for personal registration

This commit is contained in:
richjohnrambo
2026-09-23 11:33:16 +08:00
parent ac20f1ed25
commit c4355ac236
2 changed files with 8 additions and 1 deletions
+5 -1
View File
@@ -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) 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) logs.Warn.Println("create user: invalid registration account fields, sid=", s.sid)
s.queueOut(decodeStoreError(types.ErrPolicy, msg.Id, msg.Timestamp, s.queueOut(decodeStoreError(types.ErrPolicy, msg.Id, msg.Timestamp,
map[string]any{"what": "account", "reason": "REGISTRATION_ACCOUNT_INVALID"})) map[string]any{"what": "account", "reason": "REGISTRATION_ACCOUNT_INVALID"}))
+3
View File
@@ -84,6 +84,9 @@ func TestRegistrationSecretForAccount(t *testing.T) {
if got := string(registrationSecretForAccount([]byte("+8613800138000:secret"), "abcxyz123456")); got != "abcxyz123456:secret" { if got := string(registrationSecretForAccount([]byte("+8613800138000:secret"), "abcxyz123456")); got != "abcxyz123456:secret" {
t.Fatalf("got %q", got) 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) { func TestValidateAccountRegistrationTenantDefaultsEnterpriseFromSession(t *testing.T) {