From fae55c0e09cb07d0cf2355f582c72057cc4df0b2 Mon Sep 17 00:00:00 2001 From: Gaelle Braud Date: Wed, 15 Apr 2026 13:45:02 +0200 Subject: [PATCH] improve ui/ux when FAM send 422 on register with phone number #LINQT-2458 --- Linphone/core/register/RegisterPage.cpp | 8 ++++++++ Linphone/core/register/RegisterPage.hpp | 1 + Linphone/model/account/AccountManager.cpp | 4 +++- Linphone/model/account/AccountManager.hpp | 1 + .../view/Page/Form/Register/RegisterPage.qml | 20 ++++++++++++++++++- 5 files changed, 32 insertions(+), 2 deletions(-) diff --git a/Linphone/core/register/RegisterPage.cpp b/Linphone/core/register/RegisterPage.cpp index 06a1474be..faa8a506f 100644 --- a/Linphone/core/register/RegisterPage.cpp +++ b/Linphone/core/register/RegisterPage.cpp @@ -86,6 +86,14 @@ void RegisterPage::registerNewAccount(const QString &username, accountManager = nullptr; } }); + connect(accountManager, &AccountManager::phoneNumberValidationNotAvailable, this, + [this, accountManager]() mutable { + App::postCoreAsync([this]() { emit phoneNumberValidationNotAvailable(); }); + if (accountManager) { + accountManager->deleteLater(); + accountManager = nullptr; + } + }); connect(accountManager, &AccountManager::tokenConversionSucceed, this, [this, accountManager, address](QString convertedToken) { App::postCoreAsync([this, convertedToken, address]() { diff --git a/Linphone/core/register/RegisterPage.hpp b/Linphone/core/register/RegisterPage.hpp index ad96bf6db..054f6851c 100644 --- a/Linphone/core/register/RegisterPage.hpp +++ b/Linphone/core/register/RegisterPage.hpp @@ -53,6 +53,7 @@ signals: const QString &sipIdentityAddress); void registerNewAccountFailed(const QString &error); void errorInField(const QString &field, const QString &error); + void phoneNumberValidationNotAvailable(); void tokenConversionSucceed(); void linkingNewAccountWithCodeSucceed(); void linkingNewAccountWithCodeFailed(const QString &error); diff --git a/Linphone/model/account/AccountManager.cpp b/Linphone/model/account/AccountManager.cpp index f745a04c8..fdc9940a8 100644 --- a/Linphone/model/account/AccountManager.cpp +++ b/Linphone/model/account/AccountManager.cpp @@ -311,7 +311,9 @@ void AccountManager::registerNewAccount(const QString &username, } else if (request->getType() == linphone::AccountManagerServicesRequest::Type::SendPhoneNumberLinkingCodeBySms) { lInfo() << "[AccountManager] error sending code to phone number" << errorMessage; - if (parameterErrors) { + if (statusCode == 422) { + emit phoneNumberValidationNotAvailable(); + } else if (parameterErrors) { for (const std::string &key : parameterErrors->getKeys()) { emit errorInField(Utils::coreStringToAppString(key), Utils::coreStringToAppString(errorMessage)); diff --git a/Linphone/model/account/AccountManager.hpp b/Linphone/model/account/AccountManager.hpp index f3f5f3c95..a6e72a782 100644 --- a/Linphone/model/account/AccountManager.hpp +++ b/Linphone/model/account/AccountManager.hpp @@ -66,6 +66,7 @@ signals: void errorInField(const QString &field, const QString &error); void linkingNewAccountWithCodeSucceed(); void linkingNewAccountWithCodeFailed(const QString &error); + void phoneNumberValidationNotAvailable(); private: std::shared_ptr mAccountModel; diff --git a/Linphone/view/Page/Form/Register/RegisterPage.qml b/Linphone/view/Page/Form/Register/RegisterPage.qml index c79ece1fc..10fc31ddc 100644 --- a/Linphone/view/Page/Form/Register/RegisterPage.qml +++ b/Linphone/view/Page/Form/Register/RegisterPage.qml @@ -15,6 +15,21 @@ LoginLayout { readonly property string phoneNumber: phoneNumberInput.phoneNumber readonly property string email: emailInput.text + Dialog { + id: phoneNumberNotAvailableDialog + //: Phone number validation not available + title: qsTr("phone_number_validation_not_available_title") + //: Phone number validation is not available, please use email account creation process + text: qsTr("phone_number_validation_not_available_text") + //: Register with an email + firstButtonText: qsTr("register_with_email_button") + onAccepted: { + bar.setCurrentIndex(1) + close() + } + onRejected: close() + } + Connections { target: RegisterPageCpp function onErrorInField(field, errorMessage) { @@ -29,6 +44,9 @@ LoginLayout { console.log("register failed", errorMessage) otherErrorText.setText(errorMessage) } + function onPhoneNumberValidationNotAvailable() { + phoneNumberNotAvailableDialog.open() + } } titleContent: [ @@ -99,8 +117,8 @@ LoginLayout { spacing: Utils.getSizeWithScreenRatio(50) TabBar { - Layout.fillWidth: true id: bar + Layout.fillWidth: true spacing: Utils.getSizeWithScreenRatio(40) Layout.rightMargin: Math.max(Utils.getSizeWithScreenRatio(5), Utils.getSizeWithScreenRatio(127 - ((127/(DefaultStyle.defaultWidth - mainWindow.minimumWidth))*(DefaultStyle.defaultWidth-mainWindow.width)))) // "S'inscrire avec un numéro de téléphone"