fix: accept raw phone secret for personal registration
This commit is contained in:
+5
-1
@@ -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"}))
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user