!92 需求26172

Merge pull request !92 from 何思胜/openkylin/huanghe
This commit is contained in:
nil 2024-11-14 01:20:03 +00:00 committed by Gitee
commit 89069277cb
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
26 changed files with 3210 additions and 1956 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 38 KiB

BIN
data/en_US/image/account-add.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 88 KiB

BIN
data/en_US/image/set-question.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 78 KiB

View File

@ -418,13 +418,6 @@ Manage and configure system users, allowing administrators to create users, dele
![Fig 26-2 Change password](image/24.png)
#### Frogot password
- After the "Change Password" authentication fails, if a security question has been set, you can click "Forgot Password" to reset the password by verifying the security question
![Fig 30-3-1 Forgot password](image/forgot-password.png)
![Fig 30-3-2 Reset password](image/reset-password.png)
#### Change Account Type
There are two types of system users: standard users and administrator users.
@ -444,7 +437,7 @@ Editing user groups allows for adding, deleting, modifying, and querying user gr
#### Other Users
Administrator can modify other user's information, new user, and detete user, etc..
- Add new user:Enter the username, nickname, password, and select the user type,check Set password security questions to set the account security questions, and reset the password by answering the security questions when you forget the password. as shown in the image
- Add new user:Enter the username, nickname, password, password prompt, and select the user type,check Set password security questions to set the account security questions, and reset the password by answering the security questions when you forget the password. as shown in the image
![Fig 26-5 Add user](image/account-add.png)
@ -453,16 +446,6 @@ Administrator can modify other user's information, new user, and detete user, et
- Edit user
![Fig 26-7 Edit user](image/27.png)
#### Edit Groups
Editing user groups allows for adding, deleting, modifying, and querying user groups.
![Fig 25-6 Add new user](image/account-add.png)
![Fig 30-6-2 Set Question](image/set-question.png)
- Edit user
### Login Options
Login options can be configured

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 75 KiB

View File

@ -27,14 +27,6 @@
![图 2-3 更改密码](image/account-pwd.png)
#### 忘记密码
“修改密码”认证失败后,若已设置安全问题,则可点击“忘记密码”,通过校验安全问题重置密码
![图 2-3-1 忘记密码](image/forgot-pwd.png)
![图 2-3-2 重置密码](image/reset-pwd.png)
#### 更改账户类型
系统用户类型分两种:标准用户和管理员用户。
@ -56,7 +48,7 @@ Tips系统至少需要存在一个管理员用户。
可编辑其他用户信息,添加新用户,删除用户等。
- 添加新用户:输入用户名、密码,并选择用户类型,勾选设置密码安全问题可设置该账户安全问题,在忘记密码时通过回答安全问题重置密码,如图所示
- 添加新用户:输入用户名、密码,密码提示,并选择用户类型,勾选设置密码安全问题可设置该账户安全问题,在忘记密码时通过回答安全问题重置密码,如图所示
![图 2-5 添加新用户](image/account-add.png)

View File

@ -61,30 +61,6 @@ ChangeUserPwd::ChangeUserPwd(QString n, QWidget *parent) :
setupConnect();
}
ChangeUserPwd::ChangeUserPwd(QString n, bool isReset, QWidget *parent) :
QDialog(parent),
name(n),
m_isReset(isReset)
{
//判断是否是当前用户
if (QString::compare(name, QString(g_get_user_name())) == 0){
isCurrentUser = true;
} else {
isCurrentUser = false;
}
//构造密码校验线程
thread1ForCheckPwd = new PwdCheckThread(this);
makeSurePwqualityEnabled();
initUI();
setupStatus(name);
setupConnect();
}
ChangeUserPwd::~ChangeUserPwd()
{
}
@ -193,7 +169,8 @@ void ChangeUserPwd::initUI()
surePwdLineEdit = new KPasswordEdit(this);
surePwdLineEdit->setFixedSize(QSize(322, 36));
surePwdLineEdit->setPlaceholderText(placehoderText);
auto placehoder = tr("Verification");
surePwdLineEdit->setPlaceholderText(placehoder);
surePwdLineEdit->setEchoMode(QLineEdit::Password);
surePwdLineEdit->setValidator(inputLimits);
surePwdLineEdit->setTextMargins(0,0,30,0);
@ -223,27 +200,60 @@ void ChangeUserPwd::initUI()
surePwdWithTipVerLayout->addLayout(surePwdHorLayout);
surePwdWithTipVerLayout->addLayout(tipHorLayout);
// 密码提示
m_pPasswordPromptLabel = new QLabel();
m_pPasswordPromptLabel->setFixedSize(100,24);
setTextDynamicInPwd(m_pPasswordPromptLabel, tr("Password Prompt"));
m_pPasswordPromptLineedit = new QLineEdit(this);
m_pPasswordPromptLineedit->setFixedSize(QSize(322, 36));
m_pPasswordPromptLineedit->setPlaceholderText(tr("Optional(Recommended)"));
m_pPasswordPromptLineedit->setTextMargins(0,0,30,0);
m_pPasswordPromptLineedit->setContextMenuPolicy(Qt::NoContextMenu);
m_pPasswordPromptLineedit->installEventFilter(this);
QHBoxLayout *pwdPromptHLayout = new QHBoxLayout;
pwdPromptHLayout->setSpacing(8);
pwdPromptHLayout->setContentsMargins(0, 0, 0, 0);
pwdPromptHLayout->addWidget(m_pPasswordPromptLabel);
pwdPromptHLayout->addWidget(m_pPasswordPromptLineedit);
m_pPasswordPromptTips = new QLabel();
m_pPasswordPromptTips->setFont(ft);
m_pPasswordPromptTips->setFixedSize(QSize(322, 30));
m_pPasswordPromptTips->setStyleSheet("color:red;");
QHBoxLayout *passwordPromptTipsHLayout = new QHBoxLayout;
passwordPromptTipsHLayout->setSpacing(0);
passwordPromptTipsHLayout->setContentsMargins(110, 0, 0, 0);
passwordPromptTipsHLayout->addStretch();
passwordPromptTipsHLayout->addWidget(m_pPasswordPromptTips);
QVBoxLayout *pwdPromptWithTipVerLayout = new QVBoxLayout;
pwdPromptWithTipVerLayout->setSpacing(8);
pwdPromptWithTipVerLayout->setContentsMargins(0, 0, 0, 0);
pwdPromptWithTipVerLayout->addLayout(pwdPromptHLayout);
pwdPromptWithTipVerLayout->addLayout(passwordPromptTipsHLayout);
//中部输入区域
contentVerLayout = new QVBoxLayout;
contentVerLayout->setSpacing(0);
contentVerLayout->setContentsMargins(24, 0, 35, 0);
if (isCurrentUser && !m_isReset) {
if (isCurrentUser) {
contentVerLayout->addLayout(currentPwdHorLayout);
contentVerLayout->addLayout(curTipHorLayout);
setFixedSize(QSize(480, 266));
setFixedSize(QSize(480, 322));
} else {
currentPwdLabel->setVisible(false);
currentPwdLineEdit->setVisible(false);
curTipLabel->setVisible(false);
setFixedSize(480, 206);
setFixedSize(480, 272);
}
contentVerLayout->addLayout(newPwdHorLayout);
contentVerLayout->addLayout(newTipHorLayout);
contentVerLayout->addLayout(surePwdWithTipVerLayout);
contentVerLayout->addLayout(pwdPromptWithTipVerLayout);
//底部“取消”、“确定”按钮
m_pForgetPasswordBtn = new KBorderlessButton(tr("Forgot password"));
m_pForgetPasswordBtn->hide();
cancelBtn = new QPushButton();
cancelBtn->setMinimumWidth(96);
cancelBtn->setText(tr("Cancel"));
@ -256,7 +266,6 @@ void ChangeUserPwd::initUI()
bottomBtnsHorLayout = new QHBoxLayout;
bottomBtnsHorLayout->setSpacing(16);
bottomBtnsHorLayout->setContentsMargins(24, 0, 24, 0);
bottomBtnsHorLayout->addWidget(m_pForgetPasswordBtn);
bottomBtnsHorLayout->addStretch();
bottomBtnsHorLayout->addWidget(cancelBtn);
bottomBtnsHorLayout->addWidget(confirmBtn);
@ -272,7 +281,6 @@ void ChangeUserPwd::initUI()
void ChangeUserPwd::setupConnect()
{
connect(m_pForgetPasswordBtn, &KBorderlessButton::clicked, this, &ChangeUserPwd::showSecurityQuestion);
//通用的connect
connect(cancelBtn, &QPushButton::clicked, this, [=]{
@ -282,6 +290,8 @@ void ChangeUserPwd::setupConnect()
connect(newPwdLineEdit, &QLineEdit::textEdited, [=]{
checkPwdLegality();
passwordPromptChangedSlot();
refreshConfirmBtnStatus();
});
@ -297,64 +307,61 @@ void ChangeUserPwd::setupConnect()
refreshConfirmBtnStatus();
});
connect(m_pPasswordPromptLineedit, &QLineEdit::textChanged, this, &ChangeUserPwd::passwordPromptChangedSlot);
//需要区分的connect
if (isCurrentUser){
if (m_isReset) {
connect(confirmBtn, &QPushButton::clicked, this, [=]{
//重置当前用户密码
emit resetCurrentPwd(newPwdLineEdit->text());
if (isCurrentUser) {
connect(thread1ForCheckPwd, &PwdCheckThread::complete, this, &ChangeUserPwd::checkPwdFinishedSlot);
this->accept();
});
} else {
connect(currentPwdLineEdit, &QLineEdit::textEdited, [=](QString txt){
if (!txt.isEmpty()){
curPwdTip = "";
updateTipLableInfo(curTipLabel, curPwdTip);
connect(thread1ForCheckPwd, &PwdCheckThread::complete, this, &ChangeUserPwd::checkPwdFinishedSlot);
//再次校验新密码,需要保证"与旧密码相同"等条件生效
checkPwdLegality();
connect(currentPwdLineEdit, &QLineEdit::textEdited, [=](QString txt){
if (!txt.isEmpty()){
curPwdTip = "";
updateTipLableInfo(curTipLabel, curPwdTip);
}
//再次校验新密码,需要保证"与旧密码相同"等条件生效
checkPwdLegality();
refreshConfirmBtnStatus();
});
}
connect(confirmBtn, &QPushButton::clicked, [=]{
//密码校验失败有几秒延时,防止用户重复点击确定按钮
if (isChecking)
return;
refreshConfirmBtnStatus();
});
thread1ForCheckPwd->setArgs(name, currentPwdLineEdit->text());
thread1ForCheckPwd->start();
connect(confirmBtn, &QPushButton::clicked, [=]{
//密码校验失败有几秒延时,防止用户重复点击确定按钮
if (isChecking)
return;
//开始当前密码校验
isChecking = true;
thread1ForCheckPwd->setArgs(name, currentPwdLineEdit->text());
thread1ForCheckPwd->start();
//开始当前密码校验
isChecking = true;
if(m_timer == nullptr)
{
m_timer = new QTimer(this);
m_timer->setInterval(150);
connect(m_timer, &QTimer::timeout, this, &ChangeUserPwd::updatePixmap);
m_waitingPixmap = QIcon::fromTheme("ukui-loading-0-symbolic").pixmap(24, 24);
confirmBtn->setIcon(QIcon(m_waitingPixmap));
confirmBtn->setText(tr(""));
m_timer->start();
} else {
confirmBtn->setIconSize(QSize(24,24));
confirmBtn->setText(tr(""));
m_timer->start();
}
});
}
if(m_timer == nullptr)
{
m_timer = new QTimer(this);
m_timer->setInterval(150);
connect(m_timer, &QTimer::timeout, this, &ChangeUserPwd::updatePixmap);
m_waitingPixmap = QIcon::fromTheme("ukui-loading-0-symbolic").pixmap(24, 24);
confirmBtn->setIcon(QIcon(m_waitingPixmap));
confirmBtn->setText(tr(""));
m_timer->start();
} else {
confirmBtn->setIconSize(QSize(24,24));
confirmBtn->setText(tr(""));
m_timer->start();
}
});
} else {
connect(confirmBtn, &QPushButton::clicked, this, [=]{
//修改其他用户密码
emit changeOtherUserPwd(newPwdLineEdit->text());
// 绑定密码提示需要用户id
if (m_pPasswordPromptTips->text().isEmpty()) {
emit changeOtherUserPrompt(m_pPasswordPromptLineedit->text());
}
this->accept();
});
}
@ -417,6 +424,14 @@ void ChangeUserPwd::checkPwdFinishedSlot(QString re)
pclose(stream);
}
// 绑定密码提示需要用户id
if (m_pPasswordPromptTips->text().isEmpty()) {
UniAuthService *uniauthBackendDbus = new UniAuthService();
uniauthBackendDbus->deleteLater();
int ret = uniauthBackendDbus->SetUserPasswordHint(getuid(), m_pPasswordPromptLineedit->text());
qDebug() << "reply of SetUserPasswordHint in changeUserPwd = " << ret;
}
this->accept();
if (UkccCommon::isDomainUser(g_get_user_name())) {
@ -431,12 +446,6 @@ void ChangeUserPwd::checkPwdFinishedSlot(QString re)
curPwdTip = tr("Authentication failed, input authtok again!");
}
UniAuthService *uniauthBackendDbus = new UniAuthService();
uniauthBackendDbus->deleteLater();
if (uniauthBackendDbus->IsUserHasSecurityAnswers(getuid())) {
m_pForgetPasswordBtn->show();
}
updateTipLableInfo(curTipLabel,curPwdTip);
//重置当前密码输入框
@ -453,6 +462,17 @@ void ChangeUserPwd::checkPwdFinishedSlot(QString re)
}
}
void ChangeUserPwd::passwordPromptChangedSlot()
{
if (m_pPasswordPromptLineedit->text().contains(newPwdLineEdit->text())) {
updateTipLableInfo(m_pPasswordPromptTips, tr("Your password cannot be included in the password prompt."));
} else {
updateTipLableInfo(m_pPasswordPromptTips, "");
}
refreshConfirmBtnStatus();
}
void ChangeUserPwd::updatePixmap()
{
QMatrix matrix;
@ -461,12 +481,6 @@ void ChangeUserPwd::updatePixmap()
confirmBtn->setIcon(m_waitingPixmap);
}
void ChangeUserPwd::showSecurityQuestion()
{
this->accept();
emit forgetPassword();
}
void ChangeUserPwd::setupStatus(QString n)
{
@ -497,25 +511,29 @@ void ChangeUserPwd::refreshCloseBtnStatus(){
}
}
void ChangeUserPwd::refreshConfirmBtnStatus(){
if (getuid() && isCurrentUser && !m_isReset){
if (!tipLabel->text().isEmpty() || \
currentPwdLineEdit->text().isEmpty() || currentPwdLineEdit->text() == tr("Current Pwd") || \
newPwdLineEdit->text().isEmpty() || newPwdLineEdit->text() == tr("New Pwd") || \
void ChangeUserPwd::refreshConfirmBtnStatus()
{
if (getuid() && isCurrentUser) {
if (!tipLabel->text().isEmpty() ||
currentPwdLineEdit->text().isEmpty() || currentPwdLineEdit->text() == tr("Current Pwd") ||
newPwdLineEdit->text().isEmpty() || newPwdLineEdit->text() == tr("New Pwd") ||
surePwdLineEdit->text().isEmpty() || surePwdLineEdit->text() == tr("Sure Pwd") ||
!curPwdTip.isEmpty() || !newPwdTip.isEmpty() || !surePwdTip.isEmpty())
confirmBtn->setEnabled(false);
else
!curPwdTip.isEmpty() || !newPwdTip.isEmpty() || !surePwdTip.isEmpty()
|| !m_pPasswordPromptTips->text().isEmpty()) {
confirmBtn->setEnabled(false);
} else {
confirmBtn->setEnabled(true);
}
} else {
if (!tipLabel->text().isEmpty() || \
newPwdLineEdit->text().isEmpty() || newPwdLineEdit->text() == tr("New Pwd") || \
if (!tipLabel->text().isEmpty() ||
newPwdLineEdit->text().isEmpty() || newPwdLineEdit->text() == tr("New Pwd") ||
surePwdLineEdit->text().isEmpty() || surePwdLineEdit->text() == tr("Sure Pwd") ||
!newPwdTip.isEmpty() || !surePwdTip.isEmpty())
!newPwdTip.isEmpty() || !surePwdTip.isEmpty()
|| !m_pPasswordPromptTips->text().isEmpty()) {
confirmBtn->setEnabled(false);
else
} else {
confirmBtn->setEnabled(true);
}
}
}

View File

@ -4,6 +4,8 @@
#include <QDialog>
#include <QTimer>
#include "lineeditwidget.h"
#include <kpasswordedit.h>
#include <ksecurityquestiondialog.h>
#include <kborderlessbutton.h>
@ -39,7 +41,6 @@ class ChangeUserPwd : public QDialog
public:
explicit ChangeUserPwd(QString n, QWidget *parent = nullptr);
explicit ChangeUserPwd(QString n, bool isReset, QWidget *parent = nullptr);
~ChangeUserPwd();
public:
@ -65,7 +66,6 @@ public:
QHBoxLayout *newTipHorLayout;
QHBoxLayout *sureTipHorLayout;
KBorderlessButton *m_pForgetPasswordBtn;
QPushButton * cancelBtn;
QPushButton * confirmBtn;
@ -80,6 +80,10 @@ public:
KPasswordEdit * newPwdLineEdit;
KPasswordEdit * surePwdLineEdit;
QLabel *m_pPasswordPromptLabel = nullptr;
QLineEdit *m_pPasswordPromptLineedit = nullptr;
QLabel *m_pPasswordPromptTips = nullptr;
protected:
void keyPressEvent(QKeyEvent *);
bool eventFilter(QObject *target, QEvent *event);
@ -92,7 +96,6 @@ private:
QTimer *m_timer = nullptr;
bool isCurrentUser;
bool m_isReset = false;
bool isChecking = false;
bool enablePwdQuality;
@ -110,14 +113,12 @@ private:
private slots:
void updatePixmap();
void showSecurityQuestion();
void checkPwdFinishedSlot(QString re);
void passwordPromptChangedSlot();
signals:
void changeOtherUserPwd(QString pwd);
void resetCurrentPwd(QString pwd);
void forgetPassword();
void changeOtherUserPrompt(const QString &prompt);
};
#endif // CHANGEUSERPWD_H

View File

@ -42,14 +42,20 @@ CreateUserNew::CreateUserNew(QStringList allUsers, QWidget *parent) :
CreateUserNew::~CreateUserNew()
{
if (m_pBubbleTips != nullptr) {
m_pBubbleTips = nullptr;
delete m_pBubbleTips;
}
}
void CreateUserNew::initUI()
{
setFixedSize(QSize(542, 594));
setFixedSize(QSize(540, 524));
setWindowTitle(tr("CreateUserNew"));
typeBtnGroup = new QButtonGroup;
m_pUserTypeLabel = new QLabel;
m_pUserTypeLabel->setFixedWidth(100);
m_pUserTypeLabel->setText(tr("User Type"));
usernameLabel = new QLabel;
usernameLabel->setFixedSize(100, 24);
@ -89,9 +95,13 @@ void CreateUserNew::initUI()
surePwdLabel->setText(tr("SurePwd"));
tipLabel = new QLabel;
tipLabel->setFont(ft);
tipLabel->setFixedSize(340, 36);
tipLabel->setFixedSize(340, 24);
tipLabel->setStyleSheet("color:red;");
m_pUserTypeComboBox = new QComboBox;
m_pUserTypeComboBox->setFixedWidth(296);
m_pUserTypeComboBox->addItem(tr("Standard User"));
m_pUserTypeComboBox->addItem(tr("Administrator"));
usernameLineEdit = new QLineEdit;
usernameLineEdit->setFixedWidth(340);
usernameLineEdit->setPlaceholderText(tr("Required"));
@ -107,9 +117,43 @@ void CreateUserNew::initUI()
newPwdLineEdit->setEchoMode(QLineEdit::Password);
surePwdLineEdit = new QLineEdit;
surePwdLineEdit->setFixedWidth(340);
surePwdLineEdit->setPlaceholderText(tr("verification"));
surePwdLineEdit->setPlaceholderText(tr("Verification"));
surePwdLineEdit->setEchoMode(QLineEdit::Password);
m_pUserTypeDetailBtn = new QPushButton(this);
m_pUserTypeDetailBtn->setProperty("useButtonPalette", true);
m_pUserTypeDetailBtn->setFlat(true);
m_pUserTypeDetailBtn->setFixedWidth(36);
m_pUserTypeDetailBtn->setIcon(QIcon::fromTheme("help-about-symbolic"));
m_pUserTypeDetailBtn->installEventFilter(this);
if (m_pBubbleTips == nullptr) {
m_pBubbleTips = new KBubbleWidget(this);
m_pBubbleTips->setTailPosition(TailDirection::TopDirection, TailLocation::RightLocation);
m_pBubbleTips->setTailSize(QSize(24,14));
m_pBubbleTips->setBorderRadius(6);
m_pBubbleTips->setWindowFlag(Qt::ToolTip);
m_pBubbleTips->setFixedSize(380, 157);
QHBoxLayout* layout = new QHBoxLayout(m_pBubbleTips);
QLabel* button = new QLabel(m_pBubbleTips);
QFont userTypeFont;
userTypeFont.setPixelSize(14);
button->setFont(userTypeFont);
button->setWordWrap(true);
button->setText(tr("<b>Administrator:</b>Administrators can change any system configuration, including installing and upgrading software.<br>"
"<br>"
"<b>Standard User:</b>Standard users can use the vast majority of software, and can change system configurations that do not affect other users."));
layout->addWidget(button);
m_pBubbleTips->hide();
}
// 账户类型
m_pUserTypeHLayout = new QHBoxLayout;
m_pUserTypeHLayout->setSpacing(8);
m_pUserTypeHLayout->setContentsMargins(0, 0, 0, 0);
m_pUserTypeHLayout->addWidget(m_pUserTypeLabel);
m_pUserTypeHLayout->addStretch();
m_pUserTypeHLayout->addWidget(m_pUserTypeComboBox);
m_pUserTypeHLayout->addWidget(m_pUserTypeDetailBtn);
//用户名
usernameHorLayout = new QHBoxLayout;
usernameHorLayout->setSpacing(8);
@ -177,100 +221,38 @@ void CreateUserNew::initUI()
tipHorLayout->addStretch();
tipHorLayout->addWidget(tipLabel);
//"选择账户类型"
typeNoteLabel = new QLabel;
typeNoteLabel->setFixedHeight(24);
typeNoteLabel->setText(tr("Select Type"));
// 密码提示
m_pPasswordPromptLabel = new QLabel();
m_pPasswordPromptLabel->setFixedSize(100, 24);
setCunTextDynamic(m_pPasswordPromptLabel, tr("Password Prompt"));
typeNoteHorLayout = new QHBoxLayout;
typeNoteHorLayout->setSpacing(0);
typeNoteHorLayout->setMargin(0);
typeNoteHorLayout->addWidget(typeNoteLabel);
typeNoteHorLayout->addStretch();
m_pPasswordPromptLineedit = new QLineEdit(this);
m_pPasswordPromptLineedit->setFixedWidth(340);
m_pPasswordPromptLineedit->setPlaceholderText(tr("Optional(Recommended)"));
m_pPasswordPromptLineedit->setTextMargins(0,0,30,0);
m_pPasswordPromptLineedit->setContextMenuPolicy(Qt::NoContextMenu);
m_pPasswordPromptLineedit->installEventFilter(this);
adminLabel = new QLabel;
adminLabel->setText(tr("Administrator"));
adminLabel->setFixedHeight(24);
adminDetailLabel = new QLabel;
adminDetailLabel->setText(tr("Users can make any changes they need"));
standardLabel = new QLabel;
standardLabel->setText(tr("Standard User"));
standardLabel->setFixedHeight(24);
standardDetailLabel = new QLabel;
standardDetailLabel->setText(tr("Users cannot change system settings"));
QHBoxLayout *pwdPromptHLayout = new QHBoxLayout;
pwdPromptHLayout->setSpacing(8);
pwdPromptHLayout->setContentsMargins(0, 0, 0, 0);
pwdPromptHLayout->addWidget(m_pPasswordPromptLabel);
pwdPromptHLayout->addStretch();
pwdPromptHLayout->addWidget(m_pPasswordPromptLineedit);
m_pPasswordPromptTips = new QLabel();
m_pPasswordPromptTips->setFont(ft);
m_pPasswordPromptTips->setFixedSize(340, 24);
m_pPasswordPromptTips->setStyleSheet("color:red;");
QHBoxLayout *passwordPromptTipsHLayout = new QHBoxLayout;
passwordPromptTipsHLayout->setSpacing(0);
passwordPromptTipsHLayout->addStretch();
passwordPromptTipsHLayout->addWidget(m_pPasswordPromptTips);
adminRadioBtn = new QRadioButton;
adminRadioBtn->setFixedSize(QSize(16,16));
standardRadioBtn = new QRadioButton;
standardRadioBtn->setFixedSize(QSize(16,16));
typeBtnGroup->addButton(adminRadioBtn, 1);
typeBtnGroup->addButton(standardRadioBtn, 0);
adminRadioBtn->setChecked(true);
//管理员RadioButton布局
admin1VerLayout = new QVBoxLayout;
admin1VerLayout->setSpacing(0);
admin1VerLayout->setContentsMargins(0, 20, 0, 0);
admin1VerLayout->addWidget(adminRadioBtn);
admin1VerLayout->addStretch();
admin2VerLayout = new QVBoxLayout;
admin2VerLayout->setSpacing(0);
admin2VerLayout->setMargin(0);
admin2VerLayout->addStretch();
admin2VerLayout->addWidget(adminLabel);
admin2VerLayout->addWidget(adminDetailLabel);
admin2VerLayout->addStretch();
adminHorLayout = new QHBoxLayout;
adminHorLayout->setSpacing(8);
adminHorLayout->setContentsMargins(16, 0, 0, 0);
adminHorLayout->addLayout(admin1VerLayout);
adminHorLayout->addLayout(admin2VerLayout);
adminHorLayout->addStretch();
//管理员区域
adminFrame = new QFrame;
adminFrame->setMinimumSize(QSize(473, 78));
adminFrame->setMaximumSize(QSize(16777215, 78));
adminFrame->setFrameShape(QFrame::Box);
adminFrame->setFrameStyle(QFrame::Plain);
adminFrame->setLayout(adminHorLayout);
adminFrame->installEventFilter(this);
//标准用户RadioButton布局
standard1VerLayout = new QVBoxLayout;
standard1VerLayout->setSpacing(0);
standard1VerLayout->setContentsMargins(0, 20, 0, 0);
standard1VerLayout->addWidget(standardRadioBtn);
standard1VerLayout->addStretch();
standard2VerLayout = new QVBoxLayout;
standard2VerLayout->setSpacing(0);
standard2VerLayout->setMargin(0);
standard2VerLayout->addStretch();
standard2VerLayout->addWidget(standardLabel);
standard2VerLayout->addWidget(standardDetailLabel);
standard2VerLayout->addStretch();
standardHorLayout = new QHBoxLayout;
standardHorLayout->setSpacing(8);
standardHorLayout->setContentsMargins(16, 0, 0, 0);
standardHorLayout->addLayout(standard1VerLayout);
standardHorLayout->addLayout(standard2VerLayout);
standardHorLayout->addStretch();
//标准用户区域
standardFrame = new QFrame;
standardFrame->setMinimumSize(QSize(473, 80));
standardFrame->setMaximumSize(QSize(16777215, 80));
standardFrame->setFrameShape(QFrame::Box);
standardFrame->setFrameStyle(QFrame::Plain);
standardFrame->setLineWidth(1);
standardFrame->setLayout(standardHorLayout);
standardFrame->installEventFilter(this);
QVBoxLayout *pwdPromptWithTipVerLayout = new QVBoxLayout;
pwdPromptWithTipVerLayout->setSpacing(0);
pwdPromptWithTipVerLayout->setContentsMargins(0, 0, 0, 0);
pwdPromptWithTipVerLayout->addLayout(pwdPromptHLayout);
pwdPromptWithTipVerLayout->addLayout(passwordPromptTipsHLayout);
// 安全问题
m_pSecurityQusetionChecbox = new QCheckBox();
@ -307,8 +289,10 @@ void CreateUserNew::initUI()
bottomHorLayout->addWidget(confirmBtn);
m_pScrollVLayout = new QVBoxLayout;
m_pScrollVLayout->setContentsMargins(24, 28, 24, 16);
m_pScrollVLayout->setContentsMargins(24, 0, 24, 16);
m_pScrollVLayout->setSpacing(0);
m_pScrollVLayout->addLayout(m_pUserTypeHLayout);
m_pScrollVLayout->addSpacing(24);
m_pScrollVLayout->addLayout(usernameHorLayout);
m_pScrollVLayout->addLayout(usernameTipHorLayout);
@ -323,9 +307,9 @@ void CreateUserNew::initUI()
m_pScrollVLayout->addLayout(surePwdHorLayout);
m_pScrollVLayout->addLayout(tipHorLayout);
m_pScrollVLayout->addLayout(typeNoteHorLayout);
m_pScrollVLayout->addWidget(adminFrame);
m_pScrollVLayout->addWidget(standardFrame);
m_pScrollVLayout->addLayout(pwdPromptWithTipVerLayout);
m_pScrollVLayout->addLayout(securityQusetionHLayout);
m_pScrollVLayout->addWidget(m_pSecurityQusetionTitleLabel);
m_pScrollVLayout->addWidget(m_pSecurityQuestionWidget);
@ -476,6 +460,7 @@ void CreateUserNew::setConnect()
nicknameLineEdit->setText(txt);
nameLegalityCheck2(txt);
}
if (usernameLineEdit->text().length() > USER_LENGTH) {
usernameLineEdit->setText(oldName);
} else {
@ -497,6 +482,7 @@ void CreateUserNew::setConnect()
connect(newPwdLineEdit, &QLineEdit::textEdited, this, [=](QString txt){
pwdLegalityCheck(txt);
passwordPromptChangedSlot();
});
connect(surePwdLineEdit, &QLineEdit::textEdited, this, [=](QString txt){
@ -511,6 +497,8 @@ void CreateUserNew::setConnect()
refreshConfirmBtnStatus();
});
connect(m_pPasswordPromptLineedit, &QLineEdit::textChanged, this, &CreateUserNew::passwordPromptChangedSlot);
connect(cancelBtn, &QPushButton::clicked, this, [=]{
close();
});
@ -519,7 +507,7 @@ void CreateUserNew::setConnect()
//底层创建用户存在延时,先隐藏掉创建用户界面
emit confirmCreated(usernameLineEdit->text(), nicknameLineEdit->text(), typeBtnGroup->checkedId(), newPwdLineEdit->text());
emit confirmCreated(usernameLineEdit->text(), nicknameLineEdit->text(), m_pUserTypeComboBox->currentIndex(), newPwdLineEdit->text());
close();
@ -540,10 +528,27 @@ void CreateUserNew::setConnect()
}
emit bindSecurityQuestion(usernameLineEdit->text(), listAnswerInfo);
}
// 绑定密码提示需要用户id先创建后绑定
if (m_pPasswordPromptTips->text().isEmpty()) {
emit bindPasswordTips(m_pPasswordPromptLineedit->text());
}
});
}
void CreateUserNew::makeSurePwdNeedCheck(){
void CreateUserNew::passwordPromptChangedSlot()
{
if (m_pPasswordPromptLineedit->text().contains(newPwdLineEdit->text())) {
setCunTextDynamic(m_pPasswordPromptTips, tr("Your password cannot be included in the password prompt."));
} else {
setCunTextDynamic(m_pPasswordPromptTips, "");
}
refreshConfirmBtnStatus();
}
void CreateUserNew::makeSurePwdNeedCheck()
{
#ifdef ENABLEPQ
int ret;
@ -584,13 +589,17 @@ void CreateUserNew::refreshConfirmBtnStatus()
nicknameLineEdit->text().isEmpty() ||
newPwdLineEdit->text().isEmpty() ||
surePwdLineEdit->text().isEmpty() ||
!userNameTip.isEmpty() || !nickNameTip.isEmpty() || !newPwdTip.isEmpty() || !surePwdTip.isEmpty())
!userNameTip.isEmpty() || !nickNameTip.isEmpty() ||
!newPwdTip.isEmpty() || !surePwdTip.isEmpty() ||
!m_pPasswordPromptTips->text().isEmpty()) {
confirmBtn->setEnabled(false);
else
} else {
confirmBtn->setEnabled(true);
}
if (((usernameLineEdit->text().length() >= USER_LENGTH) || (nicknameLineEdit->text().length() >= NICKNAME_LENGTH))
&& newPwdTip.isEmpty() && surePwdTip.isEmpty()
&& m_pPasswordPromptTips->text().isEmpty()
&& !usernameLineEdit->text().isEmpty()
&& !nicknameLineEdit->text().isEmpty()
&& !newPwdLineEdit->text().isEmpty()
@ -604,7 +613,6 @@ void CreateUserNew::refreshConfirmBtnStatus()
confirmBtn->setEnabled(false);
}
}
}
}
@ -784,7 +792,8 @@ bool CreateUserNew::setCunTextDynamic(QLabel *label, QString string){
}
void CreateUserNew::keyPressEvent(QKeyEvent * event){
void CreateUserNew::keyPressEvent(QKeyEvent * event)
{
switch (event->key())
{
case Qt::Key_Enter:
@ -800,14 +809,25 @@ void CreateUserNew::keyPressEvent(QKeyEvent * event){
}
}
bool CreateUserNew::eventFilter(QObject *watched, QEvent *event){
if (event->type() == QEvent::MouseButtonPress){
QMouseEvent * mouseEvent = static_cast<QMouseEvent *>(event);
if (mouseEvent->button() == Qt::LeftButton ){
if (watched == adminFrame){
adminRadioBtn->setChecked(true);
} else if (watched == standardFrame){
standardRadioBtn->setChecked(true);
bool CreateUserNew::eventFilter(QObject *watched, QEvent *event)
{
if (watched == m_pUserTypeDetailBtn) {
if (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::MouseButtonRelease
|| event->type() == QEvent::MouseButtonDblClick) {
return true;
}
if (event->type() == QEvent::HoverEnter) {
if (m_pBubbleTips != nullptr) {
m_pBubbleTips->show();
m_pBubbleTips->setParent(this);
qDebug() << "move point" << m_pUserTypeDetailBtn->x() << m_pUserTypeDetailBtn->width() << m_pUserTypeDetailBtn->y() << m_pUserTypeDetailBtn->height();
m_pBubbleTips->move(this->x() + m_pUserTypeDetailBtn->x() + m_pUserTypeDetailBtn->width()/2*3 - m_pBubbleTips->width(),
this->y() + m_pUserTypeDetailBtn->y() + m_pUserTypeDetailBtn->height()*2);
}
} else if (event->type() == QEvent::HoverLeave) {
if (m_pBubbleTips != nullptr) {
m_pBubbleTips->hide();
}
}
}

View File

@ -5,6 +5,11 @@
#include <QCheckBox>
#include <QComboBox>
#include <QScrollArea>
#include <QToolButton>
#include <kbubblewidget.h>
using namespace kdk;
#include "fixlabel.h"
#include "qtdbus/uniauthservice.h"
#include "passwdcheckutil.h"
@ -57,13 +62,7 @@ public:
QHBoxLayout * newPwdHorLayout;
QHBoxLayout * surePwdHorLayout;
QHBoxLayout * tipHorLayout;
QHBoxLayout * typeNoteHorLayout;
QHBoxLayout * adminHorLayout;
QVBoxLayout * admin1VerLayout;
QVBoxLayout * admin2VerLayout;
QHBoxLayout * standardHorLayout;
QVBoxLayout * standard1VerLayout;
QVBoxLayout * standard2VerLayout;
QHBoxLayout * m_pUserTypeHLayout;
QHBoxLayout * bottomHorLayout;
QHBoxLayout *usernameTipHorLayout;
QHBoxLayout *nicknameTipHorLayout;
@ -76,34 +75,24 @@ public:
QLabel * newPwdLabel;
QLabel * surePwdLabel;
QLabel * tipLabel;
QLabel * typeNoteLabel;
QLabel * adminLabel;
QLabel * adminDetailLabel;
QLabel * standardLabel;
QLabel * standardDetailLabel;
QLabel * m_pUserTypeLabel;
QComboBox *m_pUserTypeComboBox;
QPushButton *m_pUserTypeDetailBtn;
KBubbleWidget *m_pBubbleTips = nullptr;
QLabel *usernameTipLabel;
QLabel *nicknameTipLabel;
QLabel *hostnameTipLabel;
QLabel *newpwdTipLabel;
QLineEdit * usernameLineEdit;
QLineEdit * nicknameLineEdit;
QLineEdit *hostnameLineEdit;
QLineEdit * newPwdLineEdit;
QLineEdit * surePwdLineEdit;
QFrame * adminFrame;
QFrame * standardFrame;
QRadioButton * adminRadioBtn;
QRadioButton * standardRadioBtn;
QPushButton * cancelBtn;
QPushButton * confirmBtn;
QButtonGroup * typeBtnGroup;
QCheckBox *m_pSecurityQusetionChecbox;
FixLabel *m_pSecurityQusetionTitleLabel;
QVBoxLayout *m_pSecurityQusetionVLayout;
@ -116,6 +105,10 @@ public:
QScrollArea *m_pScrollArea;
QWidget *m_pScrollWidget;
QLabel *m_pPasswordPromptLabel = nullptr;
QLineEdit *m_pPasswordPromptLineedit = nullptr;
QLabel *m_pPasswordPromptTips = nullptr;
public:
QString userNameTip;
QString nickNameTip;
@ -149,9 +142,11 @@ private:
signals:
void confirmCreated(QString name, QString fullname, int accounttype, QString pwd);
void bindSecurityQuestion(QString name, QList<AnswerInfo> answerInfo);
void bindPasswordTips(const QString &passwordTips);
public Q_SLOTS:
void setQustionCombox();
void refreshConfirmBtnStatus();
void passwordPromptChangedSlot();
};
#endif // CREATEUSERNEW_H

View File

@ -265,3 +265,35 @@ int UniAuthService::ChangePassword(int nUId, const QString &strPasswd, QString s
return -1;
}
}
int UniAuthService::SetUserPasswordHint(int nUid, const QString &strHint)
{
QDBusMessage result = call(QStringLiteral("SetUserPasswdHint"), nUid, strHint);
if (result.type() == QDBusMessage::ErrorMessage) {
qWarning() << "GetUserPasswordHint error:" << result.errorMessage();
return -1;
}
QList<QVariant> varResult = result.arguments();
if (varResult.size() > 0) {
return varResult.takeFirst().toInt();
} else {
return -1;
}
}
QString UniAuthService::GetUserPasswordHint(int nUid)
{
QDBusMessage result = call(QStringLiteral("GetUserPasswdHint"), nUid);
if (result.type() == QDBusMessage::ErrorMessage) {
qWarning() << "GetUserPasswordHint error:" << result.errorMessage();
return QString("");
}
QList<QVariant> varResult = result.arguments();
if (varResult.size() > 0) {
return varResult.takeFirst().toString();
} else {
return QString("");
}
}

View File

@ -127,6 +127,21 @@ public Q_SLOTS:
*/
int ChangePassword(int nUId, const QString &strPasswd, QString strToken);
/**
* @brief SetUserPasswordHint
* @param nUId id
* @param strHint
* @return 0
*/
int SetUserPasswordHint(int nUid, const QString &strHint);
/**
* @brief GetUserPasswordHint
* @param nUId id
* @return
*/
QString GetUserPasswordHint(int nUid);
public:
bool isActivatable();
bool authoriyEdit();

View File

@ -529,30 +529,49 @@ void UserInfo::showCreateUserNewDialog()
usersStringList.append(user.realname);
}
qint64 uid = 0;
CreateUserNew *dialog = new CreateUserNew(usersStringList, pluginWidget2);
connect(dialog, &CreateUserNew::confirmCreated, this, [=](QString name, QString fullname, int accounttype, QString pwd){
userSettingDbus->asyncCall("createUser", name, fullname, accounttype, DEFAULTFACE, pwd);
connect(dialog, &CreateUserNew::confirmCreated, this, [&](QString name, QString fullname, int accounttype, QString pwd){
userSettingDbus->asyncCall("createUser", name, fullname, accounttype, DEFAULTFACE, pwd);
uid = getUserUid(name);
});
connect(dialog, &CreateUserNew::bindSecurityQuestion, this, [=](QString name, QList<AnswerInfo> answerInfo){
QStringList objectpaths = sysdispatcher->list_cached_users();
qint64 uid = 0;
for (QString objectpath : objectpaths){
UserInfomation user;
user = _acquireUserInfo(objectpath);
if (user.username == name) {
uid = user.uid;
}
allUserInfoMap.insert(user.username, user);
}
if (uid != 0) {
int ret = m_pUniauthBackendDbus->BindUserSecurityAnswers(uid, answerInfo);
qDebug() << "ret = " << ret;
}
});
connect(dialog, &CreateUserNew::bindPasswordTips, this, [=](const QString &text){
setPasswordTips(uid, text);
});
dialog->exec();
}
qint64 UserInfo::getUserUid(const QString &name)
{
QStringList objectpaths = sysdispatcher->list_cached_users();
qint64 uid = 0;
for (QString objectpath : objectpaths){
UserInfomation user;
user = _acquireUserInfo(objectpath);
if (user.username == name) {
uid = user.uid;
}
allUserInfoMap.insert(user.username, user);
}
return uid;
}
void UserInfo::setPasswordTips(int uid, const QString &text)
{
if (uid != 0) {
int ret = m_pUniauthBackendDbus->SetUserPasswordHint(uid, text);
qDebug() << "reply of SetUserPasswordHint = " << ret;
}
}
void UserInfo::showDeleteUserExistsDialog(QString pName)
{
QStringList loginedusers = getLoginedUsers();
@ -716,12 +735,21 @@ void UserInfo::showChangeUserPwdDialog(QString pName)
{
if (allUserInfoMap.keys().contains(pName)) {
ChangeUserPwd *dialog = new ChangeUserPwd(pName, pluginWidget2);
connect(dialog, &ChangeUserPwd::changeOtherUserPwd, this, [=](QString pwd){
QStringList objectpaths = sysdispatcher->list_cached_users();
qint64 uid = 0;
for (QString objectpath : objectpaths){
UserInfomation user;
user = _acquireUserInfo(objectpath);
if (user.username == pName) {
uid = user.uid;
}
}
connect(dialog, &ChangeUserPwd::changeOtherUserPwd, this, [=](QString pwd) {
userSettingDbus->call("changeOtherUserPasswd", pName, pwd);
});
connect(dialog, &ChangeUserPwd::forgetPassword, this, [=](){
showForgetPasswordDialog(pName);
connect(dialog, &ChangeUserPwd::changeOtherUserPrompt, this, [=](const QString &prompt) {
setPasswordTips(uid, prompt);
});
dialog->exec();
@ -731,71 +759,6 @@ void UserInfo::showChangeUserPwdDialog(QString pName)
}
}
void UserInfo::showForgetPasswordDialog(QString pName)
{
m_pVerifyQuestionDialog = new KSecurityQuestionDialog();
m_pVerifyQuestionDialog->setFixedWidth(424);
m_pVerifyQuestionDialog->deleteLater();
m_pVerifyQuestionDialog->addSecurityQuestionItem(SECURITY_QUESTION_COUNT, false, true);
m_pVerifyQuestionDialog->setWindowTitle(tr("Forgot password"));
m_pVerifyQuestionDialog->confirmButton()->setText(tr("Confirm"));
m_pVerifyQuestionDialog->setTitleText(tr("Answer the security questions to reset password"));
QList<QuestionInfo> listQuestionInfo = m_pUniauthBackendDbus->GetUserSecurityQuestions(getuid(), QLocale::system().name());
QStringList question;
for (int n = 0; n < SECURITY_QUESTION_COUNT; n++) {
auto questionInfo = listQuestionInfo.at(n);
question.append(questionInfo.strQuestionText);
qDebug() << "User Bound Question:" << questionInfo.nQuestionId << questionInfo.strQuestionText;
}
m_pVerifyQuestionDialog->initQustionCombox(question);
connect(m_pVerifyQuestionDialog->confirmButton(), &KPushButton::clicked, this, [=](){
showVerifyQuestionDialog(pName, listQuestionInfo);
});
m_pVerifyQuestionDialog->exec();
}
void UserInfo::showVerifyQuestionDialog(QString pName, QList<QuestionInfo> listQuestionInfo)
{
// 获取已绑定安全问题,填充下拉框
QList<AnswerInfo> listAnswerInfo;
for (int n = 0; n < SECURITY_QUESTION_COUNT; n++) {
auto questionInfo = listQuestionInfo.at(n);
AnswerInfo answerInfo;
answerInfo.nQuestionId = questionInfo.nQuestionId;
answerInfo.strAnswerText = m_pUniauthBackendDbus->EncodeSecurityInfo(m_pVerifyQuestionDialog->answerLineedit(n)->text());
listAnswerInfo.append(answerInfo);
qDebug() << "User Question Answer:" << questionInfo.nQuestionId << questionInfo.strQuestionText << m_pVerifyQuestionDialog->answerLineedit(n)->text();
}
// call verify get token
QString verifyToken = m_pUniauthBackendDbus->VerifyUserSecurityAnswers(getuid(), listAnswerInfo);
qDebug() << "Verify ret:" << verifyToken;
if (verifyToken.isEmpty()) {
m_pVerifyQuestionDialog->tipsLabel(SECURITY_QUESTION_COUNT - 1)->setText(tr("One or more answers are incorrect"));
} else {
m_pVerifyQuestionDialog->accept();
// close verify dialog then show reset dialog
ChangeUserPwd *dia = new ChangeUserPwd(pName, true, pluginWidget2);
dia->setWindowTitle(tr("Reset password"));
connect(dia, &ChangeUserPwd::resetCurrentPwd, this, [=](QString pwd){
showResetPasswordDialog(pwd, verifyToken);
});
dia->exec();
}
}
void UserInfo::showResetPasswordDialog(QString pwd, QString token)
{
int nRet = m_pUniauthBackendDbus->ChangePassword(getuid(), pwd, token);
qDebug() << "ChangePwd ret:" << nRet;
}
void UserInfo::showChangeUserTypeDialog(QString u)
{
if (allUserInfoMap.keys().contains(u)){

View File

@ -195,6 +195,7 @@ private:
bool openAutoLoginMsg(const QString &userName);
void showMessageBox();
QString renameFaceName(QString fullFilename, QString username);
qint64 getUserUid(const QString &name);
public slots:
void currentUserPropertyChangedSlot(QString, QMap<QString, QVariant>, QStringList);
@ -205,9 +206,7 @@ public slots:
void existsUserDeleteDoneSlot(QDBusObjectPath op);
void changeUserFace(QString facefile, QString username, UtilsForUserinfo *utilsUser);
void showForgetPasswordDialog(QString pName);
void showVerifyQuestionDialog(QString pName, QList<QuestionInfo> listQuestionInfo);
void showResetPasswordDialog(QString pwd, QString token);
void setPasswordTips(int uid, const QString &text);
Q_SIGNALS:
void userTypeChanged(QString n);

View File

@ -10,6 +10,7 @@ include($$PROJECT_ROOTDIR/libukcc/widgets/Label/label.pri)
include($$PROJECT_ROOTDIR/libukcc/widgets/AddBtn/addbtn.pri)
include($$PROJECT_ROOTDIR/libukcc/widgets/CloseButton/closebutton.pri)
include($$PROJECT_ROOTDIR/libukcc/widgets/SettingWidget/settingwidget.pri)
include($$PROJECT_ROOTDIR/libukcc/widgets/Button/button.pri)
include($$PROJECT_ROOTDIR/libukcc/interface.pri)

View File

@ -15,7 +15,7 @@
#include <QButtonGroup>
#include <QDebug>
#include <QToolButton>
#include <QFocusEvent>
#include "ukcccommon.h"
using namespace ukcc;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff