mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-17 11:28:07 +00:00
register: fix token verification part if error in account creation
This commit is contained in:
parent
77fad7ba86
commit
7970cd49f0
6 changed files with 147 additions and 103 deletions
|
|
@ -65,8 +65,11 @@ void RegisterPage::registerNewAccount(const QString &username,
|
|||
});
|
||||
connect(accountManager, &AccountManager::registerNewAccountFailed, this,
|
||||
[this, accountManager](const QString &errorMessage) mutable {
|
||||
App::postCoreAsync(
|
||||
[this, errorMessage, accountManager]() { emit registerNewAccountFailed(errorMessage); });
|
||||
App::postCoreAsync([this, errorMessage]() {
|
||||
mLastRegisterAddress.clear();
|
||||
mLastConvertedToken.clear();
|
||||
emit registerNewAccountFailed(errorMessage);
|
||||
});
|
||||
if (accountManager) {
|
||||
accountManager->deleteLater();
|
||||
accountManager = nullptr;
|
||||
|
|
@ -81,8 +84,16 @@ void RegisterPage::registerNewAccount(const QString &username,
|
|||
}
|
||||
});
|
||||
connect(accountManager, &AccountManager::tokenConversionSucceed, this,
|
||||
[this, accountManager]() { App::postCoreAsync([this]() { emit tokenConversionSucceed(); }); });
|
||||
accountManager->registerNewAccount(username, password, registerType, address);
|
||||
[this, accountManager, address](QString convertedToken) {
|
||||
App::postCoreAsync([this, convertedToken, address]() {
|
||||
mLastRegisterAddress = address;
|
||||
mLastConvertedToken = convertedToken;
|
||||
emit tokenConversionSucceed();
|
||||
});
|
||||
});
|
||||
accountManager->registerNewAccount(username, password, registerType, address,
|
||||
QString::compare(mLastRegisterAddress, address) ? QString()
|
||||
: mLastConvertedToken);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -92,7 +103,11 @@ void RegisterPage::linkNewAccountUsingCode(const QString &code,
|
|||
App::postModelAsync([=]() {
|
||||
auto accountManager = new AccountManager();
|
||||
connect(accountManager, &AccountManager::linkingNewAccountWithCodeSucceed, this, [this, accountManager]() {
|
||||
App::postCoreAsync([this]() { emit linkingNewAccountWithCodeSucceed(); });
|
||||
App::postCoreAsync([this]() {
|
||||
mLastRegisterAddress.clear();
|
||||
mLastConvertedToken.clear();
|
||||
emit linkingNewAccountWithCodeSucceed();
|
||||
});
|
||||
accountManager->deleteLater();
|
||||
});
|
||||
connect(accountManager, &AccountManager::linkingNewAccountWithCodeFailed, this,
|
||||
|
|
|
|||
|
|
@ -61,6 +61,10 @@ private:
|
|||
QSharedPointer<SafeConnection<RegisterPage, AccountManager>> mAccountManagerConnection;
|
||||
std::shared_ptr<AccountManager> mAccountManager;
|
||||
QString mErrorMessage;
|
||||
// Usefull to skip token verification part if the account
|
||||
// creation failed for an existing username
|
||||
QString mLastRegisterAddress;
|
||||
QString mLastConvertedToken;
|
||||
|
||||
DECLARE_ABSTRACT_OBJECT
|
||||
};
|
||||
|
|
|
|||
|
|
@ -132,7 +132,8 @@ bool AccountManager::login(QString username,
|
|||
void AccountManager::registerNewAccount(const QString &username,
|
||||
const QString &password,
|
||||
RegisterType type,
|
||||
const QString ®isterAddress) {
|
||||
const QString ®isterAddress,
|
||||
QString lastToken) {
|
||||
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
|
||||
if (!mAccountManagerServicesModel) {
|
||||
auto core = CoreModel::getInstance()->getCore();
|
||||
|
|
@ -163,7 +164,7 @@ void AccountManager::registerNewAccount(const QString &username,
|
|||
} else if (request->getType() == linphone::AccountManagerServicesRequest::Type::
|
||||
AccountCreationTokenFromAccountCreationRequestToken) {
|
||||
qDebug() << "[AccountManager] request token conversion succeed" << data;
|
||||
emit tokenConversionSucceed();
|
||||
emit tokenConversionSucceed(Utils::coreStringToAppString(data));
|
||||
timer.stop();
|
||||
mAccountManagerServicesModel->createAccountUsingToken(Utils::appStringToCoreString(username),
|
||||
Utils::appStringToCoreString(password), data);
|
||||
|
|
@ -253,7 +254,14 @@ void AccountManager::registerNewAccount(const QString &username,
|
|||
}
|
||||
}
|
||||
});
|
||||
mAccountManagerServicesModel->requestToken();
|
||||
if (lastToken.isEmpty()) {
|
||||
mAccountManagerServicesModel->requestToken();
|
||||
} else {
|
||||
emit tokenConversionSucceed(lastToken);
|
||||
mAccountManagerServicesModel->createAccountUsingToken(Utils::appStringToCoreString(username),
|
||||
Utils::appStringToCoreString(password),
|
||||
Utils::appStringToCoreString(lastToken));
|
||||
}
|
||||
}
|
||||
|
||||
void AccountManager::linkNewAccountUsingCode(const QString &code,
|
||||
|
|
|
|||
|
|
@ -49,7 +49,8 @@ public:
|
|||
void registerNewAccount(const QString &username,
|
||||
const QString &password,
|
||||
RegisterType type,
|
||||
const QString ®isterAddress);
|
||||
const QString ®isterAddress,
|
||||
QString lastToken = QString());
|
||||
|
||||
void linkNewAccountUsingCode(const QString &code, RegisterType registerType, const QString &sipAddress);
|
||||
|
||||
|
|
@ -61,7 +62,7 @@ signals:
|
|||
void registrationStateChanged(linphone::RegistrationState state);
|
||||
void newAccountCreationSucceed(QString sipAddress, RegisterType registerType, const QString ®isterAddress);
|
||||
void registerNewAccountFailed(const QString &error);
|
||||
void tokenConversionSucceed();
|
||||
void tokenConversionSucceed(QString convertedToken);
|
||||
void errorInField(const QString &field, const QString &error);
|
||||
void linkingNewAccountWithCodeSucceed();
|
||||
void linkingNewAccountWithCodeFailed(const QString &error);
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ Text {
|
|||
}
|
||||
Timer {
|
||||
id: autoHideErrorMessage
|
||||
interval: 2500
|
||||
interval: 5000
|
||||
onTriggered: mainItem.text = ""
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,10 @@ LoginLayout {
|
|||
else if (field == "password") pwdItem.errorMessage = errorMessage
|
||||
else if (field == "phone") phoneNumberInput.errorMessage = errorMessage
|
||||
else if (field == "email") emailItem.errorMessage = errorMessage
|
||||
else otherErrorText.text = errorMessage
|
||||
}
|
||||
function onRegisterNewAccountFailed(errorMessage) {
|
||||
otherErrorText.text = errorMessage
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -142,36 +146,47 @@ LoginLayout {
|
|||
}
|
||||
}
|
||||
}
|
||||
RowLayout {
|
||||
spacing: 16 * DefaultStyle.dp
|
||||
ColumnLayout {
|
||||
spacing: 5 * DefaultStyle.dp
|
||||
FormItemLayout {
|
||||
id: passwordItem
|
||||
label: qsTr("Mot de passe")
|
||||
mandatory: true
|
||||
enableErrorText: true
|
||||
contentItem: TextField {
|
||||
id: pwdInput
|
||||
hidden: true
|
||||
Layout.preferredWidth: 346 * DefaultStyle.dp
|
||||
backgroundBorderColor: passwordItem.errorMessage.length > 0 ? DefaultStyle.danger_500main : DefaultStyle.grey_200
|
||||
ColumnLayout {
|
||||
spacing: 0
|
||||
Layout.preferredHeight: rowlayout.height
|
||||
clip: false
|
||||
RowLayout {
|
||||
id: rowlayout
|
||||
spacing: 16 * DefaultStyle.dp
|
||||
ColumnLayout {
|
||||
spacing: 5 * DefaultStyle.dp
|
||||
FormItemLayout {
|
||||
id: passwordItem
|
||||
label: qsTr("Mot de passe")
|
||||
mandatory: true
|
||||
enableErrorText: true
|
||||
contentItem: TextField {
|
||||
id: pwdInput
|
||||
hidden: true
|
||||
Layout.preferredWidth: 346 * DefaultStyle.dp
|
||||
backgroundBorderColor: passwordItem.errorMessage.length > 0 ? DefaultStyle.danger_500main : DefaultStyle.grey_200
|
||||
}
|
||||
}
|
||||
}
|
||||
ColumnLayout {
|
||||
spacing: 5 * DefaultStyle.dp
|
||||
FormItemLayout {
|
||||
label: qsTr("Confirmation mot de passe")
|
||||
mandatory: true
|
||||
enableErrorText: true
|
||||
contentItem: TextField {
|
||||
id: confirmPwdInput
|
||||
hidden: true
|
||||
Layout.preferredWidth: 346 * DefaultStyle.dp
|
||||
backgroundBorderColor: passwordItem.errorMessage.length > 0 ? DefaultStyle.danger_500main : DefaultStyle.grey_200
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ColumnLayout {
|
||||
spacing: 5 * DefaultStyle.dp
|
||||
FormItemLayout {
|
||||
label: qsTr("Confirmation mot de passe")
|
||||
mandatory: true
|
||||
enableErrorText: true
|
||||
contentItem: TextField {
|
||||
id: confirmPwdInput
|
||||
hidden: true
|
||||
Layout.preferredWidth: 346 * DefaultStyle.dp
|
||||
backgroundBorderColor: passwordItem.errorMessage.length > 0 ? DefaultStyle.danger_500main : DefaultStyle.grey_200
|
||||
}
|
||||
}
|
||||
ErrorText {
|
||||
id: otherErrorText
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 5 * DefaultStyle.dp
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -194,80 +209,81 @@ LoginLayout {
|
|||
// }
|
||||
// }
|
||||
// }
|
||||
RowLayout {
|
||||
spacing: 10 * DefaultStyle.dp
|
||||
CheckBox {
|
||||
id: termsCheckBox
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
spacing: 0
|
||||
Layout.fillWidth: true
|
||||
Text {
|
||||
text: qsTr("J'accepte les ")
|
||||
font {
|
||||
pixelSize: 14 * DefaultStyle.dp
|
||||
weight: 400 * DefaultStyle.dp
|
||||
}
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: termsCheckBox.toggle()
|
||||
}
|
||||
spacing: 10 * DefaultStyle.dp
|
||||
CheckBox {
|
||||
id: termsCheckBox
|
||||
}
|
||||
Text {
|
||||
activeFocusOnTab: true
|
||||
font {
|
||||
underline: true
|
||||
pixelSize: 14 * DefaultStyle.dp
|
||||
weight: 400 * DefaultStyle.dp
|
||||
bold: activeFocus
|
||||
}
|
||||
text: qsTr("conditions d’utilisation")
|
||||
Keys.onPressed: (event)=> {
|
||||
if (event.key == Qt.Key_Space || event.key == Qt.Key_Enter || event.key == Qt.Key_Return) {
|
||||
cguMouseArea.clicked(undefined)
|
||||
event.accepted = true;
|
||||
RowLayout {
|
||||
spacing: 0
|
||||
Layout.fillWidth: true
|
||||
Text {
|
||||
text: qsTr("J'accepte les ")
|
||||
font {
|
||||
pixelSize: 14 * DefaultStyle.dp
|
||||
weight: 400 * DefaultStyle.dp
|
||||
}
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: termsCheckBox.toggle()
|
||||
}
|
||||
}
|
||||
MouseArea {
|
||||
id: cguMouseArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: containsMouse ? Qt.PointingHandCursor : Qt.ArrowCursor
|
||||
onClicked: Qt.openUrlExternally(ConstantsCpp.CguUrl)
|
||||
}
|
||||
}
|
||||
Text {
|
||||
text: qsTr(" et la ")
|
||||
font {
|
||||
pixelSize: 14 * DefaultStyle.dp
|
||||
weight: 400 * DefaultStyle.dp
|
||||
}
|
||||
}
|
||||
Text {
|
||||
activeFocusOnTab: true
|
||||
font {
|
||||
underline: true
|
||||
pixelSize: 14 * DefaultStyle.dp
|
||||
weight: 400 * DefaultStyle.dp
|
||||
bold: activeFocus
|
||||
}
|
||||
text: qsTr("politique de confidentialité.")
|
||||
Keys.onPressed: (event)=> {
|
||||
if (event.key == Qt.Key_Space || event.key == Qt.Key_Enter || event.key == Qt.Key_Return) {
|
||||
privateMouseArea.clicked(undefined)
|
||||
event.accepted = true;
|
||||
Text {
|
||||
activeFocusOnTab: true
|
||||
font {
|
||||
underline: true
|
||||
pixelSize: 14 * DefaultStyle.dp
|
||||
weight: 400 * DefaultStyle.dp
|
||||
bold: activeFocus
|
||||
}
|
||||
text: qsTr("conditions d’utilisation")
|
||||
Keys.onPressed: (event)=> {
|
||||
if (event.key == Qt.Key_Space || event.key == Qt.Key_Enter || event.key == Qt.Key_Return) {
|
||||
cguMouseArea.clicked(undefined)
|
||||
event.accepted = true;
|
||||
}
|
||||
}
|
||||
MouseArea {
|
||||
id: cguMouseArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: containsMouse ? Qt.PointingHandCursor : Qt.ArrowCursor
|
||||
onClicked: Qt.openUrlExternally(ConstantsCpp.CguUrl)
|
||||
}
|
||||
}
|
||||
MouseArea {
|
||||
id: privateMouseArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: containsMouse ? Qt.PointingHandCursor : Qt.ArrowCursor
|
||||
onClicked: Qt.openUrlExternally(ConstantsCpp.PrivatePolicyUrl)
|
||||
Text {
|
||||
text: qsTr(" et la ")
|
||||
font {
|
||||
pixelSize: 14 * DefaultStyle.dp
|
||||
weight: 400 * DefaultStyle.dp
|
||||
}
|
||||
}
|
||||
Text {
|
||||
activeFocusOnTab: true
|
||||
font {
|
||||
underline: true
|
||||
pixelSize: 14 * DefaultStyle.dp
|
||||
weight: 400 * DefaultStyle.dp
|
||||
bold: activeFocus
|
||||
}
|
||||
text: qsTr("politique de confidentialité.")
|
||||
Keys.onPressed: (event)=> {
|
||||
if (event.key == Qt.Key_Space || event.key == Qt.Key_Enter || event.key == Qt.Key_Return) {
|
||||
privateMouseArea.clicked(undefined)
|
||||
event.accepted = true;
|
||||
}
|
||||
}
|
||||
MouseArea {
|
||||
id: privateMouseArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: containsMouse ? Qt.PointingHandCursor : Qt.ArrowCursor
|
||||
onClicked: Qt.openUrlExternally(ConstantsCpp.PrivatePolicyUrl)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// }
|
||||
Button {
|
||||
enabled: termsCheckBox.checked
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue