feat: Make user id and user password input max length to 30.

This commit is contained in:
sunwen
2024-06-20 17:21:01 +08:00
parent 23f8aea990
commit fd8632e888
2 changed files with 12 additions and 1 deletions

View File

@@ -57,6 +57,8 @@ AccountFormDialog::AccountFormDialog(QWidget* parent, AccountEditMode mode, Qt::
mNewUserName = text; mNewUserName = text;
mUserNameChanged = true; mUserNameChanged = true;
}); });
mLeUserCode->setMaxLength(30);
} }
void AccountFormDialog::addEndLine(QVBoxLayout* layout) void AccountFormDialog::addEndLine(QVBoxLayout* layout)
@@ -182,6 +184,7 @@ void AccountFormDialog::addNewModeUI(QVBoxLayout* layout)
mLePwd = new ULineEdit(this); mLePwd = new ULineEdit(this);
mLePwd->setPlaceholderText(tr("Input password")); mLePwd->setPlaceholderText(tr("Input password"));
mLePwd->setEchoMode(QLineEdit::Password); mLePwd->setEchoMode(QLineEdit::Password);
mLePwd->setMaxLength(30);
layout->addWidget(mLePwd); layout->addWidget(mLePwd);
mRoleID = User::getRoleID("doctor"); mRoleID = User::getRoleID("doctor");
addEndLine(layout); addEndLine(layout);
@@ -192,6 +195,7 @@ void AccountFormDialog::addNewModeUI(QVBoxLayout* layout)
mConfirmPwd = new ULineEdit(this); mConfirmPwd = new ULineEdit(this);
mConfirmPwd->setPlaceholderText(tr("Input password")); mConfirmPwd->setPlaceholderText(tr("Input password"));
mConfirmPwd->setEchoMode(QLineEdit::Password); mConfirmPwd->setEchoMode(QLineEdit::Password);
mConfirmPwd->setMaxLength(30);
layout->addWidget(mConfirmPwd); layout->addWidget(mConfirmPwd);
addEndLine(layout); addEndLine(layout);
} }
@@ -266,6 +270,11 @@ bool AccountFormDialog::updateReferenceData()
warn(tr("Password can't be empty!")); warn(tr("Password can't be empty!"));
return false; return false;
} }
if (mLePwd->text().length() < 6)
{
warn(tr("Password should at least 6 characters!"));
return false;
}
if (mLePwd->text() != mConfirmPwd->text()) if (mLePwd->text() != mConfirmPwd->text())
{ {
warn(tr("Password and confirm password do not match!")); warn(tr("Password and confirm password do not match!"));

View File

@@ -129,6 +129,7 @@ void LoginDialog::initializeEdit()
mAccountEdit->setObjectName("combobox_UserName"); mAccountEdit->setObjectName("combobox_UserName");
mAccountEdit->setPlaceholderText(tr("Username")); mAccountEdit->setPlaceholderText(tr("Username"));
mAccountEdit->setFocusPolicy(Qt::ClickFocus); mAccountEdit->setFocusPolicy(Qt::ClickFocus);
mAccountEdit->setMaxLength(30);
accountEditAreaLayout->addWidget(mAccountEdit); accountEditAreaLayout->addWidget(mAccountEdit);
accountEditAreaLayout->addItem(new QSpacerItem(49,20,QSizePolicy::Fixed)); accountEditAreaLayout->addItem(new QSpacerItem(49,20,QSizePolicy::Fixed));
mDialogContentsLayout->addWidget(accountEditArea); mDialogContentsLayout->addWidget(accountEditArea);
@@ -140,6 +141,7 @@ void LoginDialog::initializeEdit()
mPasswordEdit->setEchoMode(QLineEdit::Password); mPasswordEdit->setEchoMode(QLineEdit::Password);
mPasswordEdit->setPlaceholderText(tr("Password")); mPasswordEdit->setPlaceholderText(tr("Password"));
mPasswordEdit->setFocusPolicy(Qt::ClickFocus); mPasswordEdit->setFocusPolicy(Qt::ClickFocus);
mPasswordEdit->setMaxLength(30);
passwordEditAreaLayout->addWidget(mPasswordEdit); passwordEditAreaLayout->addWidget(mPasswordEdit);
passwordEditAreaLayout->addWidget(mShowPasswordButton); passwordEditAreaLayout->addWidget(mShowPasswordButton);
mShowPasswordButton->setObjectName("ShowPasswordButton"); mShowPasswordButton->setObjectName("ShowPasswordButton");
@@ -186,7 +188,7 @@ void LoginDialog::doLogin()
{ {
if (!(AppGlobalValues::DBconnected().toBool())) if (!(AppGlobalValues::DBconnected().toBool()))
{ {
mErrorMessage->setText(QString(tr("Can't connect db. Please reboot the device and retry, or call for the service help.")).arg(LOGIN_LOCK_MINUTIES)); mErrorMessage->setText(tr("Can't connect db. Please reboot the device and retry, or call for the service help."));
mErrorMessage->setVisible(true); mErrorMessage->setVisible(true);
return; return;
} }