fix: Fix password can input chinese character bug.

This commit is contained in:
sunwen
2024-06-21 15:09:06 +08:00
parent 77b077e253
commit 5e768b7e9c
3 changed files with 11 additions and 1 deletions

View File

@@ -184,6 +184,7 @@ void AccountFormDialog::addNewModeUI(QVBoxLayout* layout)
mLePwd = new ULineEdit(this);
mLePwd->setPlaceholderText(tr("Input password"));
mLePwd->setEchoMode(QLineEdit::Password);
mLePwd->setValidator(new QRegExpValidator(QRegExp("[a-zA-z0-9]+$"), mLePwd));
mLePwd->setMaxLength(30);
layout->addWidget(mLePwd);
mRoleID = User::getRoleID("doctor");
@@ -195,6 +196,7 @@ void AccountFormDialog::addNewModeUI(QVBoxLayout* layout)
mConfirmPwd = new ULineEdit(this);
mConfirmPwd->setPlaceholderText(tr("Input password"));
mConfirmPwd->setEchoMode(QLineEdit::Password);
mConfirmPwd->setValidator(new QRegExpValidator(QRegExp("[a-zA-z0-9]+$"), mConfirmPwd));
mConfirmPwd->setMaxLength(30);
layout->addWidget(mConfirmPwd);
addEndLine(layout);

View File

@@ -2,6 +2,7 @@
#include <QVBoxLayout>
#include <QLabel>
#include <QRegExpValidator>
#include "components/ULineEdit.h"
#include "models/User.h"
@@ -33,6 +34,8 @@ void ChangePasswordFormDialog::initLayout()
lblOld->setText(tr("Current Password"));
mLEPasswd->setEchoMode(QLineEdit::Password);
mLEPasswd->setValidator(new QRegExpValidator(QRegExp("[a-zA-z0-9]+$"), mLEPasswd));
mLEPasswd->setMaxLength(30);
layout->addWidget(lblOld);
layout->addWidget(mLEPasswd);
auto lblEndline1 = new QLabel(this);
@@ -45,6 +48,8 @@ void ChangePasswordFormDialog::initLayout()
lblNewPasswd->setText(tr("New Password"));
mLENewPasswd->setEchoMode(QLineEdit::Password);
mLENewPasswd->setValidator(new QRegExpValidator(QRegExp("[a-zA-z0-9]+$"), mLENewPasswd));
mLENewPasswd->setMaxLength(30);
layout->addWidget(lblNewPasswd);
layout->addWidget(mLENewPasswd);
auto lblEndline2 = new QLabel(this);
@@ -57,6 +62,8 @@ void ChangePasswordFormDialog::initLayout()
lblConfirm->setText(tr("Confirm Password"));
mLEConfirmPasswd->setEchoMode(QLineEdit::Password);
mLEConfirmPasswd->setValidator(new QRegExpValidator(QRegExp("[a-zA-z0-9]+$"), mLEConfirmPasswd));
mLEConfirmPasswd->setMaxLength(30);
layout->addWidget(lblConfirm);
layout->addWidget(mLEConfirmPasswd);
auto lblEndline3 = new QLabel(this);

View File

@@ -141,6 +141,7 @@ void LoginDialog::initializeEdit()
mPasswordEdit->setEchoMode(QLineEdit::Password);
mPasswordEdit->setPlaceholderText(tr("Password"));
mPasswordEdit->setFocusPolicy(Qt::ClickFocus);
mPasswordEdit->setValidator(new QRegExpValidator(QRegExp("[a-zA-z0-9]+$"), mPasswordEdit));
mPasswordEdit->setMaxLength(30);
passwordEditAreaLayout->addWidget(mPasswordEdit);
passwordEditAreaLayout->addWidget(mShowPasswordButton);
@@ -206,7 +207,7 @@ void LoginDialog::doLogin()
QString strPassWord = mPasswordEdit->text();
QString encryptedPassword = strPassWord;
//strPassWord = "123456";
strPassWord = "123456";
QString encryptPwd = User::getEncryptedPassword(strPassWord);
if (User::QueryUser(strUserCode, encryptPwd))