mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-23 12:08:53 +00:00
fix: password count and disable repeat until first is valid
cleanup
This commit is contained in:
parent
d797880e6e
commit
fad0bb858e
@ -20,9 +20,8 @@ ModalPopup {
|
|||||||
if (passwordInput.text === "") {
|
if (passwordInput.text === "") {
|
||||||
//% "You need to enter a password"
|
//% "You need to enter a password"
|
||||||
passwordValidationError = qsTrId("you-need-to-enter-a-password")
|
passwordValidationError = qsTrId("you-need-to-enter-a-password")
|
||||||
} else if (passwordInput.text.length < 4) {
|
} else if (passwordInput.text.length < 6) {
|
||||||
//% "Password needs to be 4 characters or more"
|
passwordValidationError = qsTr("Password needs to be 6 characters or more")
|
||||||
passwordValidationError = qsTrId("password-needs-to-be-4-characters-or-more")
|
|
||||||
} else {
|
} else {
|
||||||
passwordValidationError = ""
|
passwordValidationError = ""
|
||||||
}
|
}
|
||||||
|
@ -24,9 +24,8 @@ ModalPopup {
|
|||||||
if (passwordInput.text === "") {
|
if (passwordInput.text === "") {
|
||||||
//% "You need to enter a password"
|
//% "You need to enter a password"
|
||||||
passwordValidationError = qsTrId("you-need-to-enter-a-password")
|
passwordValidationError = qsTrId("you-need-to-enter-a-password")
|
||||||
} else if (passwordInput.text.length < 4) {
|
} else if (passwordInput.text.length < 6) {
|
||||||
//% "Password needs to be 4 characters or more"
|
passwordValidationError = qsTr("Password needs to be 6 characters or more")
|
||||||
passwordValidationError = qsTrId("password-needs-to-be-4-characters-or-more")
|
|
||||||
} else {
|
} else {
|
||||||
passwordValidationError = ""
|
passwordValidationError = ""
|
||||||
}
|
}
|
||||||
|
@ -18,9 +18,8 @@ ModalPopup {
|
|||||||
if (passwordInput.text === "") {
|
if (passwordInput.text === "") {
|
||||||
//% "You need to enter a password"
|
//% "You need to enter a password"
|
||||||
passwordValidationError = qsTrId("you-need-to-enter-a-password")
|
passwordValidationError = qsTrId("you-need-to-enter-a-password")
|
||||||
} else if (passwordInput.text.length < 4) {
|
} else if (passwordInput.text.length < 6) {
|
||||||
//% "Password needs to be 4 characters or more"
|
passwordValidationError = qsTr("Password needs to be 6 characters or more")
|
||||||
passwordValidationError = qsTrId("password-needs-to-be-4-characters-or-more")
|
|
||||||
} else {
|
} else {
|
||||||
passwordValidationError = ""
|
passwordValidationError = ""
|
||||||
}
|
}
|
||||||
|
@ -197,4 +197,31 @@ QtObject {
|
|||||||
default: return network
|
default: return network
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function validate(item, firstPasswordField, repeatPasswordField) {
|
||||||
|
console.log("validate");
|
||||||
|
switch (item) {
|
||||||
|
case "first":
|
||||||
|
if (firstPasswordField.text === "") {
|
||||||
|
//% "You need to enter a password"
|
||||||
|
return [false, qsTrId("you-need-to-enter-a-password")];
|
||||||
|
} else if (firstPasswordField.text.length < 6) {
|
||||||
|
return [false, qsTrId("Password needs to be 6 characters or more")];
|
||||||
|
}
|
||||||
|
return [true, ""];
|
||||||
|
|
||||||
|
case "repeat":
|
||||||
|
if (repeatPasswordField.text === "") {
|
||||||
|
//% "You need to repeat your password"
|
||||||
|
return [false, qsTrId("you-need-to-repeat-your-password")];
|
||||||
|
} else if (repeatPasswordField.text !== firstPasswordField.text) {
|
||||||
|
//% Both passwords must match
|
||||||
|
return [true, qsTrId("both-passwords-must-match")];
|
||||||
|
}
|
||||||
|
return [true, ""];
|
||||||
|
|
||||||
|
default:
|
||||||
|
return [false, ""];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,33 +7,11 @@ import "../shared/status"
|
|||||||
|
|
||||||
ModalPopup {
|
ModalPopup {
|
||||||
property bool loading: false
|
property bool loading: false
|
||||||
|
property bool firstPasswordFieldValid: false
|
||||||
|
property bool repeatPasswordFieldValid: false
|
||||||
property string passwordValidationError: ""
|
property string passwordValidationError: ""
|
||||||
property string repeatPasswordValidationError: ""
|
property string repeatPasswordValidationError: ""
|
||||||
|
|
||||||
function validate() {
|
|
||||||
if (firstPasswordField.text === "") {
|
|
||||||
//% "You need to enter a password"
|
|
||||||
passwordValidationError = qsTrId("you-need-to-enter-a-password")
|
|
||||||
} else if (firstPasswordField.text.length < 4) {
|
|
||||||
//% "Password needs to be 4 characters or more"
|
|
||||||
passwordValidationError = qsTrId("password-needs-to-be-4-characters-or-more")
|
|
||||||
} else {
|
|
||||||
passwordValidationError = ""
|
|
||||||
}
|
|
||||||
|
|
||||||
if (repeatPasswordField.text === "") {
|
|
||||||
//% "You need to repeat your password"
|
|
||||||
repeatPasswordValidationError = qsTrId("you-need-to-repeat-your-password")
|
|
||||||
} else if (repeatPasswordField.text !== firstPasswordField.text) {
|
|
||||||
//% "Both passwords must match"
|
|
||||||
repeatPasswordValidationError = qsTrId("both-passwords-must-match")
|
|
||||||
} else {
|
|
||||||
repeatPasswordValidationError = ""
|
|
||||||
}
|
|
||||||
|
|
||||||
return passwordValidationError === "" && repeatPasswordValidationError === ""
|
|
||||||
}
|
|
||||||
|
|
||||||
id: popup
|
id: popup
|
||||||
//% "Create a password"
|
//% "Create a password"
|
||||||
title: qsTrId("intro-wizard-title-alt4")
|
title: qsTrId("intro-wizard-title-alt4")
|
||||||
@ -54,10 +32,15 @@ ModalPopup {
|
|||||||
placeholderText: qsTrId("new-password...")
|
placeholderText: qsTrId("new-password...")
|
||||||
textField.echoMode: TextInput.Password
|
textField.echoMode: TextInput.Password
|
||||||
validationError: popup.passwordValidationError
|
validationError: popup.passwordValidationError
|
||||||
|
onTextChanged: {
|
||||||
|
[firstPasswordFieldValid, passwordValidationError] =
|
||||||
|
Utils.validate("first", firstPasswordField, repeatPasswordField);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Input {
|
Input {
|
||||||
id: repeatPasswordField
|
id: repeatPasswordField
|
||||||
|
enabled: firstPasswordFieldValid
|
||||||
anchors.rightMargin: 0
|
anchors.rightMargin: 0
|
||||||
anchors.leftMargin: 0
|
anchors.leftMargin: 0
|
||||||
anchors.right: firstPasswordField.right
|
anchors.right: firstPasswordField.right
|
||||||
@ -71,6 +54,10 @@ ModalPopup {
|
|||||||
Keys.onReturnPressed: {
|
Keys.onReturnPressed: {
|
||||||
submitBtn.clicked()
|
submitBtn.clicked()
|
||||||
}
|
}
|
||||||
|
onTextChanged: {
|
||||||
|
[repeatPasswordFieldValid, repeatPasswordValidationError] =
|
||||||
|
Utils.validate("repeat", firstPasswordField, repeatPasswordField);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StyledText {
|
StyledText {
|
||||||
@ -103,7 +90,7 @@ ModalPopup {
|
|||||||
//% "Create password"
|
//% "Create password"
|
||||||
text: qsTrId("create-password")
|
text: qsTrId("create-password")
|
||||||
|
|
||||||
enabled: firstPasswordField.text !== "" && repeatPasswordField.text !== "" && !loading
|
enabled: firstPasswordFieldValid && repeatPasswordFieldValid && !loading
|
||||||
|
|
||||||
MessageDialog {
|
MessageDialog {
|
||||||
id: importError
|
id: importError
|
||||||
@ -144,10 +131,6 @@ ModalPopup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (!validate()) {
|
|
||||||
errorSound.play()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
loading = true
|
loading = true
|
||||||
loginModel.isCurrentFlow = false;
|
loginModel.isCurrentFlow = false;
|
||||||
onboardingModel.isCurrentFlow = true;
|
onboardingModel.isCurrentFlow = true;
|
||||||
|
@ -13,8 +13,7 @@ Item {
|
|||||||
property alias validationError: txtPassword.validationError
|
property alias validationError: txtPassword.validationError
|
||||||
//% "You need to enter a password"
|
//% "You need to enter a password"
|
||||||
property string noInputErrorMessage: qsTrId("you-need-to-enter-a-password")
|
property string noInputErrorMessage: qsTrId("you-need-to-enter-a-password")
|
||||||
//% "Password needs to be 4 characters or more"
|
property string invalidInputErrorMessage: qsTr("Password needs to be 6 characters or more")
|
||||||
property string invalidInputErrorMessage: qsTrId("password-needs-to-be-4-characters-or-more")
|
|
||||||
property bool isValid: false
|
property bool isValid: false
|
||||||
|
|
||||||
function forceActiveFocus(reason) {
|
function forceActiveFocus(reason) {
|
||||||
@ -26,7 +25,7 @@ Item {
|
|||||||
const noInput = txtPassword.text === ""
|
const noInput = txtPassword.text === ""
|
||||||
if (noInput) {
|
if (noInput) {
|
||||||
txtPassword.validationError = noInputErrorMessage
|
txtPassword.validationError = noInputErrorMessage
|
||||||
} else if (txtPassword.text.length < 4) {
|
} else if (txtPassword.text.length < 6) {
|
||||||
txtPassword.validationError = invalidInputErrorMessage
|
txtPassword.validationError = invalidInputErrorMessage
|
||||||
}
|
}
|
||||||
isValid = txtPassword.validationError === ""
|
isValid = txtPassword.validationError === ""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user