816 lines
28 KiB
Diff
816 lines
28 KiB
Diff
From 7fe0be8d4bca4bc59f755bc2ec521b0c750e95b0 Mon Sep 17 00:00:00 2001
|
||
From: liuxinhao <liuxinhao@kylinsec.com.cn>
|
||
Date: Mon, 29 May 2023 20:12:06 +0800
|
||
Subject: [PATCH 1/3] fix(auth): Verify the current password when logging
|
||
features
|
||
MIME-Version: 1.0
|
||
Content-Type: text/plain; charset=UTF-8
|
||
Content-Transfer-Encoding: 8bit
|
||
|
||
- 录入特征时,校验当前密码
|
||
|
||
Closes #I795QI
|
||
---
|
||
CMakeLists.txt | 1 +
|
||
.../input-dialog/input-dialog.cpp | 45 ++++---
|
||
.../input-dialog/input-dialog.h | 20 ++--
|
||
plugins/authentication/CMakeLists.txt | 1 +
|
||
.../authentication/src/checkpasswd-dialog.cpp | 110 ++++++++++++++++++
|
||
...n-rename-dialog.h => checkpasswd-dialog.h} | 28 +----
|
||
.../src/identification-rename-dialog.cpp | 108 -----------------
|
||
.../src/pages/face/face-page.cpp | 2 +-
|
||
.../src/pages/finger/finger-page.cpp | 3 +-
|
||
.../src/pages/iris/iris-page.cpp | 2 +-
|
||
.../src/pages/ukey/ukey-page.cpp | 11 +-
|
||
.../src/widgets/general-bio-page.cpp | 44 +++++--
|
||
.../src/widgets/general-bio-page.h | 5 +-
|
||
.../kiran-cpanel-authentication.zh_CN.ts | 27 ++++-
|
||
translations/kiran-control-panel.zh_CN.ts | 26 +++++
|
||
15 files changed, 254 insertions(+), 179 deletions(-)
|
||
rename plugins/authentication/src/ukey-pin-input-dialog.cpp => lib/common-widgets/input-dialog/input-dialog.cpp (74%)
|
||
rename plugins/authentication/src/ukey-pin-input-dialog.h => lib/common-widgets/input-dialog/input-dialog.h (72%)
|
||
create mode 100644 plugins/authentication/src/checkpasswd-dialog.cpp
|
||
rename plugins/authentication/src/{identification-rename-dialog.h => checkpasswd-dialog.h} (51%)
|
||
delete mode 100644 plugins/authentication/src/identification-rename-dialog.cpp
|
||
|
||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||
index f5b2cce..bdffa50 100644
|
||
--- a/CMakeLists.txt
|
||
+++ b/CMakeLists.txt
|
||
@@ -41,6 +41,7 @@ configure_file(${CMAKE_SOURCE_DIR}/data/${PROJECT_NAME}.pc.in ${CMAKE_BINARY_DIR
|
||
|
||
file(GLOB_RECURSE INCLUDE_SRC "./include/*")
|
||
file(GLOB_RECURSE CONTROL_PANEL_SRC "./src/*")
|
||
+file(GLOB_RECURSE LIB_SRC "./lib/*")
|
||
set(RESOURCE ./resources/control-panel-resources.qrc) #资源文件名不能与插件资源名相同,否则会导致插件中部分图片无法正常加载显示。
|
||
|
||
file(GLOB TS_FILES "translations/*.ts")
|
||
diff --git a/plugins/authentication/src/ukey-pin-input-dialog.cpp b/lib/common-widgets/input-dialog/input-dialog.cpp
|
||
similarity index 74%
|
||
rename from plugins/authentication/src/ukey-pin-input-dialog.cpp
|
||
rename to lib/common-widgets/input-dialog/input-dialog.cpp
|
||
index 312043b..e7305c3 100644
|
||
--- a/plugins/authentication/src/ukey-pin-input-dialog.cpp
|
||
+++ b/lib/common-widgets/input-dialog/input-dialog.cpp
|
||
@@ -1,16 +1,15 @@
|
||
-#include "ukey-pin-input-dialog.h"
|
||
+#include "input-dialog.h"
|
||
#include <kiran-color-block.h>
|
||
-#include <kiran-passwd-edit.h>
|
||
#include <style-property.h>
|
||
+#include <kiran-passwd-edit.h>
|
||
#include <QBoxLayout>
|
||
#include <QEventLoop>
|
||
#include <QLabel>
|
||
#include <QLineEdit>
|
||
#include <QPushButton>
|
||
#include <qt5-log-i.h>
|
||
-#include "utils/kiran-auth-dbus-proxy.h"
|
||
|
||
-UKeyPinCodeDialog::UKeyPinCodeDialog(QWidget* parent)
|
||
+InputDialog::InputDialog(QWidget* parent)
|
||
: KiranTitlebarWindow(parent,Qt::Dialog),
|
||
m_success(false)
|
||
{
|
||
@@ -18,31 +17,42 @@ UKeyPinCodeDialog::UKeyPinCodeDialog(QWidget* parent)
|
||
initUI();
|
||
}
|
||
|
||
-UKeyPinCodeDialog::~UKeyPinCodeDialog()
|
||
+InputDialog::~InputDialog()
|
||
{
|
||
}
|
||
|
||
-QString UKeyPinCodeDialog::getPinCode()
|
||
+QString InputDialog::getText()
|
||
{
|
||
return m_edit->lineEdit()->text();
|
||
}
|
||
|
||
-int UKeyPinCodeDialog::exec()
|
||
+void InputDialog::setDesc(const QString&desc)
|
||
+{
|
||
+ m_labelDesc->setText(desc);
|
||
+}
|
||
+
|
||
+void InputDialog::setInputMode(QLineEdit::EchoMode mode,qint32 maxLength)
|
||
+{
|
||
+ m_edit->setEchoMode(mode);
|
||
+ m_edit->lineEdit()->setMaxLength(maxLength);
|
||
+}
|
||
+
|
||
+int InputDialog::exec()
|
||
{
|
||
QEventLoop loop;
|
||
- connect(this, &UKeyPinCodeDialog::completed, &loop, &QEventLoop::quit);
|
||
+ connect(this, &InputDialog::completed, &loop, &QEventLoop::quit);
|
||
this->show();
|
||
loop.exec(QEventLoop::DialogExec);
|
||
return m_success;
|
||
}
|
||
|
||
-void UKeyPinCodeDialog::closeEvent(QCloseEvent* event)
|
||
+void InputDialog::closeEvent(QCloseEvent* event)
|
||
{
|
||
- emit completed(QPrivateSignal());
|
||
+ emit completed();
|
||
return KiranTitlebarWindow::closeEvent(event);
|
||
}
|
||
|
||
-void UKeyPinCodeDialog::onConfirmClicked()
|
||
+void InputDialog::onConfirmClicked()
|
||
{
|
||
QString text = m_edit->lineEdit()->text();
|
||
if (text.isEmpty())
|
||
@@ -50,15 +60,14 @@ void UKeyPinCodeDialog::onConfirmClicked()
|
||
return;
|
||
}
|
||
m_success = true;
|
||
- emit completed(QPrivateSignal());
|
||
+ emit completed();
|
||
}
|
||
|
||
-void UKeyPinCodeDialog::initUI()
|
||
+void InputDialog::initUI()
|
||
{
|
||
setTitlebarColorBlockEnable(true);
|
||
setButtonHints(TitlebarCloseButtonHint);
|
||
setResizeable(false);
|
||
- setTitle(tr("UKey Enroll"));
|
||
|
||
auto container = new QWidget(this);
|
||
auto containerLayout = new QBoxLayout(QBoxLayout::TopToBottom, container);
|
||
@@ -71,8 +80,8 @@ void UKeyPinCodeDialog::initUI()
|
||
auto layout = new QBoxLayout(QBoxLayout::TopToBottom, colorBlock);
|
||
layout->setContentsMargins(24, 24, 24, 24);
|
||
|
||
- auto label = new QLabel(tr("Please enter the ukey pin code"), this);
|
||
- layout->addWidget(label);
|
||
+ m_labelDesc = new QLabel(this);
|
||
+ layout->addWidget(m_labelDesc);
|
||
|
||
layout->addSpacerItem(new QSpacerItem(10, 16, QSizePolicy::Minimum, QSizePolicy::Fixed));
|
||
|
||
@@ -92,7 +101,7 @@ void UKeyPinCodeDialog::initUI()
|
||
confirmButton->setFixedSize(QSize(110, 40));
|
||
confirmButton->setText(tr("Confirm"));
|
||
Kiran::StylePropertyHelper::setButtonType(confirmButton, Kiran::BUTTON_Default);
|
||
- connect(confirmButton, &QPushButton::clicked, this, &UKeyPinCodeDialog::onConfirmClicked);
|
||
+ connect(confirmButton, &QPushButton::clicked, this, &InputDialog::onConfirmClicked);
|
||
boxlayout->addWidget(confirmButton);
|
||
|
||
boxlayout->addSpacerItem(new QSpacerItem(40, 10, QSizePolicy::Fixed, QSizePolicy::Minimum));
|
||
@@ -101,7 +110,7 @@ void UKeyPinCodeDialog::initUI()
|
||
cancelButton->setFixedSize(QSize(110, 40));
|
||
cancelButton->setText(tr("Cancel"));
|
||
connect(cancelButton, &QPushButton::clicked, this, [this]()
|
||
- { emit completed(QPrivateSignal()); });
|
||
+ { emit completed(); });
|
||
boxlayout->addWidget(cancelButton);
|
||
|
||
boxlayout->addStretch();
|
||
diff --git a/plugins/authentication/src/ukey-pin-input-dialog.h b/lib/common-widgets/input-dialog/input-dialog.h
|
||
similarity index 72%
|
||
rename from plugins/authentication/src/ukey-pin-input-dialog.h
|
||
rename to lib/common-widgets/input-dialog/input-dialog.h
|
||
index 064577d..39e1cd1 100644
|
||
--- a/plugins/authentication/src/ukey-pin-input-dialog.h
|
||
+++ b/lib/common-widgets/input-dialog/input-dialog.h
|
||
@@ -13,21 +13,24 @@
|
||
*/
|
||
#pragma once
|
||
#include <kiranwidgets-qt5/kiran-titlebar-window.h>
|
||
+#include <QLineEdit>
|
||
|
||
-class KiranAuthDBusProxy;
|
||
class KiranPasswdEdit;
|
||
-class UKeyPinCodeDialog : public KiranTitlebarWindow
|
||
+class QLabel;
|
||
+class InputDialog : public KiranTitlebarWindow
|
||
{
|
||
Q_OBJECT
|
||
public:
|
||
- UKeyPinCodeDialog(QWidget* parent = nullptr);
|
||
- ~UKeyPinCodeDialog();
|
||
+ InputDialog(QWidget* parent = nullptr);
|
||
+ ~InputDialog();
|
||
|
||
- QString getPinCode();
|
||
- int exec();
|
||
+ void setDesc(const QString&desc);
|
||
+ void setInputMode(QLineEdit::EchoMode mode,qint32 maxLength);
|
||
+ virtual int exec();
|
||
|
||
+ QString getText();
|
||
signals:
|
||
- void completed(QPrivateSignal);
|
||
+ void completed();
|
||
|
||
private:
|
||
virtual void closeEvent(QCloseEvent* event) override;
|
||
@@ -38,7 +41,6 @@ private:
|
||
|
||
private:
|
||
bool m_success;
|
||
+ QLabel* m_labelDesc;
|
||
KiranPasswdEdit* m_edit;
|
||
- QString m_iid;
|
||
- KiranAuthDBusProxy* m_proxy;
|
||
};
|
||
\ No newline at end of file
|
||
diff --git a/plugins/authentication/CMakeLists.txt b/plugins/authentication/CMakeLists.txt
|
||
index d86b032..952df96 100644
|
||
--- a/plugins/authentication/CMakeLists.txt
|
||
+++ b/plugins/authentication/CMakeLists.txt
|
||
@@ -41,6 +41,7 @@ target_link_libraries(${TARGET_NAME}
|
||
Qt5::Widgets
|
||
Qt5::DBus
|
||
Qt5::Svg
|
||
+ pam
|
||
${KIRAN_WIDGETS_LIBRARIES}
|
||
${KLOG_LIBRARIES}
|
||
${KIRAN_STYLE_LIBRARIES}
|
||
diff --git a/plugins/authentication/src/checkpasswd-dialog.cpp b/plugins/authentication/src/checkpasswd-dialog.cpp
|
||
new file mode 100644
|
||
index 0000000..f116966
|
||
--- /dev/null
|
||
+++ b/plugins/authentication/src/checkpasswd-dialog.cpp
|
||
@@ -0,0 +1,110 @@
|
||
+#include "checkpasswd-dialog.h"
|
||
+#include <security/pam_appl.h>
|
||
+#include <qt5-log-i.h>
|
||
+#include <pwd.h>
|
||
+#include <unistd.h>
|
||
+
|
||
+int conv_func(int num_msg, const struct pam_message **msg,
|
||
+ struct pam_response **resp, void *appdata_ptr)
|
||
+{
|
||
+ struct pam_response *reply = NULL;
|
||
+ int ret;
|
||
+ int replies;
|
||
+ char *passwd = (char *)appdata_ptr;
|
||
+
|
||
+ ///分配回复包
|
||
+ reply = (struct pam_response *)calloc(num_msg, sizeof(*reply));
|
||
+ if (reply == nullptr)
|
||
+ {
|
||
+ return PAM_CONV_ERR;
|
||
+ }
|
||
+
|
||
+ ret = PAM_SUCCESS;
|
||
+ //给每个ECHO_OFF消息填充密码,若出现ECHO_ON消息认证失败,释放
|
||
+ for (replies = 0; replies < num_msg && ret == PAM_SUCCESS; replies++)
|
||
+ {
|
||
+ if (msg[replies]->msg_style == PAM_PROMPT_ECHO_ON)
|
||
+ {
|
||
+ goto failed;
|
||
+ }
|
||
+ reply[replies].resp = new char[strlen(passwd) + 1]();
|
||
+ strcpy(reply[replies].resp, passwd);
|
||
+ reply[replies].resp_retcode = PAM_SUCCESS;
|
||
+ }
|
||
+ *resp = reply;
|
||
+ return PAM_SUCCESS;
|
||
+
|
||
+failed:
|
||
+ ///释放之前分配的内存
|
||
+ for (int i = 0; i < replies; i++)
|
||
+ {
|
||
+ if (reply[i].resp != nullptr)
|
||
+ {
|
||
+ delete reply[i].resp;
|
||
+ }
|
||
+ }
|
||
+ free(reply);
|
||
+ return PAM_CONV_ERR;
|
||
+}
|
||
+
|
||
+void no_fail_delay(int status, unsigned int delay, void *appdata_ptr)
|
||
+{
|
||
+}
|
||
+
|
||
+bool _checkUserPassword(const QString &user, const QString &pwd)
|
||
+{
|
||
+ KLOG_DEBUG() << "start check user passwd";
|
||
+ std::string sPwd = pwd.toStdString();
|
||
+ struct pam_conv conv = {
|
||
+ &conv_func,
|
||
+ (void *)sPwd.c_str()};
|
||
+
|
||
+ pam_handle *handler;
|
||
+ int res;
|
||
+
|
||
+ res = pam_start("password-auth", user.toStdString().c_str(),
|
||
+ &conv,
|
||
+ &handler);
|
||
+
|
||
+ pam_set_item(handler, PAM_FAIL_DELAY, (void *)no_fail_delay);
|
||
+
|
||
+ res = pam_authenticate(handler, 0);
|
||
+ if (res != PAM_SUCCESS)
|
||
+ {
|
||
+ KLOG_DEBUG() << "check user passwd:"<< pam_strerror(handler, res) << res;
|
||
+ }
|
||
+
|
||
+ pam_end(handler, res);
|
||
+ KLOG_DEBUG() << "end check user passwd";
|
||
+ return res == PAM_SUCCESS;
|
||
+}
|
||
+
|
||
+QString getCurrentUser()
|
||
+{
|
||
+ auto pwd = getpwuid(getuid());
|
||
+ return pwd?pwd->pw_name:"";
|
||
+}
|
||
+
|
||
+CheckpasswdDialog::CheckpasswdDialog(QWidget* parent)
|
||
+ :InputDialog(parent)
|
||
+{
|
||
+ setTitle(tr("Check password"));
|
||
+ setDesc(tr("Check the current password before you enroll the feature"));
|
||
+ setInputMode(QLineEdit::Password,32);
|
||
+}
|
||
+
|
||
+CheckpasswdDialog::~CheckpasswdDialog()
|
||
+{
|
||
+
|
||
+}
|
||
+
|
||
+bool CheckpasswdDialog::checkPasswd(const QString& passwd)
|
||
+{
|
||
+ auto currentUser = getCurrentUser();
|
||
+ if( currentUser.isEmpty() )
|
||
+ {
|
||
+ return false;
|
||
+ }
|
||
+
|
||
+ return _checkUserPassword(currentUser,passwd);
|
||
+}
|
||
\ No newline at end of file
|
||
diff --git a/plugins/authentication/src/identification-rename-dialog.h b/plugins/authentication/src/checkpasswd-dialog.h
|
||
similarity index 51%
|
||
rename from plugins/authentication/src/identification-rename-dialog.h
|
||
rename to plugins/authentication/src/checkpasswd-dialog.h
|
||
index f692fb9..f482345 100644
|
||
--- a/plugins/authentication/src/identification-rename-dialog.h
|
||
+++ b/plugins/authentication/src/checkpasswd-dialog.h
|
||
@@ -12,32 +12,14 @@
|
||
* Author: liuxinhao <liuxinhao@kylinsec.com.cn>
|
||
*/
|
||
#pragma once
|
||
-#include <kiranwidgets-qt5/kiran-titlebar-window.h>
|
||
+#include "input-dialog/input-dialog.h"
|
||
|
||
-class KiranAuthDBusProxy;
|
||
-class QLineEdit;
|
||
-class IdentificationRenameDialog : public KiranTitlebarWindow
|
||
+class CheckpasswdDialog:public InputDialog
|
||
{
|
||
Q_OBJECT
|
||
public:
|
||
- IdentificationRenameDialog(const QString& iid, KiranAuthDBusProxy* proxy, QWidget* parent = nullptr);
|
||
- ~IdentificationRenameDialog();
|
||
+ CheckpasswdDialog(QWidget* parent = nullptr);
|
||
+ ~CheckpasswdDialog();
|
||
|
||
- int exec();
|
||
-
|
||
-signals:
|
||
- void completed(QPrivateSignal);
|
||
-
|
||
-private:
|
||
- virtual void closeEvent(QCloseEvent* event) override;
|
||
- Q_INVOKABLE void onConfirmClicked();
|
||
-
|
||
-private:
|
||
- void initUI();
|
||
-
|
||
-private:
|
||
- bool m_success;
|
||
- QLineEdit* m_edit;
|
||
- QString m_iid;
|
||
- KiranAuthDBusProxy* m_proxy;
|
||
+ static bool checkPasswd(const QString& passwd);
|
||
};
|
||
\ No newline at end of file
|
||
diff --git a/plugins/authentication/src/identification-rename-dialog.cpp b/plugins/authentication/src/identification-rename-dialog.cpp
|
||
deleted file mode 100644
|
||
index a554283..0000000
|
||
--- a/plugins/authentication/src/identification-rename-dialog.cpp
|
||
+++ /dev/null
|
||
@@ -1,108 +0,0 @@
|
||
-#include "identification-rename-dialog.h"
|
||
-#include <kiran-color-block.h>
|
||
-#include <style-property.h>
|
||
-#include <QBoxLayout>
|
||
-#include <QEventLoop>
|
||
-#include <QLabel>
|
||
-#include <QLineEdit>
|
||
-#include <QPushButton>
|
||
-#include <qt5-log-i.h>
|
||
-#include "utils/kiran-auth-dbus-proxy.h"
|
||
-
|
||
-IdentificationRenameDialog::IdentificationRenameDialog(const QString& iid, KiranAuthDBusProxy* proxy, QWidget* parent)
|
||
- : KiranTitlebarWindow(parent,Qt::Dialog),
|
||
- m_iid(iid),
|
||
- m_proxy(proxy),
|
||
- m_success(false)
|
||
-{
|
||
- setAttribute(Qt::WA_ShowModal, true);
|
||
- initUI();
|
||
-}
|
||
-
|
||
-IdentificationRenameDialog::~IdentificationRenameDialog()
|
||
-{
|
||
-}
|
||
-
|
||
-int IdentificationRenameDialog::exec()
|
||
-{
|
||
- QEventLoop loop;
|
||
- connect(this, &IdentificationRenameDialog::completed, &loop, &QEventLoop::quit);
|
||
- this->show();
|
||
- loop.exec(QEventLoop::DialogExec);
|
||
- return m_success;
|
||
-}
|
||
-
|
||
-void IdentificationRenameDialog::closeEvent(QCloseEvent* event)
|
||
-{
|
||
- emit completed(QPrivateSignal());
|
||
- return KiranTitlebarWindow::closeEvent(event);
|
||
-}
|
||
-
|
||
-void IdentificationRenameDialog::onConfirmClicked()
|
||
-{
|
||
- QString text = m_edit->text();
|
||
- if (text.isEmpty())
|
||
- {
|
||
- return;
|
||
- }
|
||
- m_proxy->renameIdentification(m_iid, text);
|
||
- m_success = true;
|
||
- emit completed(QPrivateSignal());
|
||
-}
|
||
-
|
||
-void IdentificationRenameDialog::initUI()
|
||
-{
|
||
- setTitlebarColorBlockEnable(true);
|
||
- setButtonHints(TitlebarCloseButtonHint);
|
||
- setResizeable(false);
|
||
- setTitle(tr("Rename Feature"));
|
||
-
|
||
- auto container = new QWidget(this);
|
||
- auto containerLayout = new QBoxLayout(QBoxLayout::TopToBottom, container);
|
||
- containerLayout->setContentsMargins(4, 4, 4, 4);
|
||
-
|
||
- auto colorBlock = new KiranColorBlock(container);
|
||
- colorBlock->setDrawBackground(true);
|
||
- containerLayout->addWidget(colorBlock);
|
||
-
|
||
- auto layout = new QBoxLayout(QBoxLayout::TopToBottom, colorBlock);
|
||
- layout->setContentsMargins(24, 24, 24, 24);
|
||
-
|
||
- auto label = new QLabel(tr("Please enter the renamed feature name"), this);
|
||
- layout->addWidget(label);
|
||
-
|
||
- layout->addSpacerItem(new QSpacerItem(10, 16, QSizePolicy::Minimum, QSizePolicy::Fixed));
|
||
-
|
||
- m_edit = new QLineEdit(this);
|
||
- m_edit->setMaxLength(30);
|
||
- layout->addWidget(m_edit);
|
||
-
|
||
- layout->addSpacerItem(new QSpacerItem(10, 16, QSizePolicy::Minimum, QSizePolicy::Fixed));
|
||
-
|
||
- auto boxlayout = new QBoxLayout(QBoxLayout::LeftToRight);
|
||
- boxlayout->setContentsMargins(0, 0, 0, 0);
|
||
-
|
||
- boxlayout->addStretch();
|
||
-
|
||
- auto confirmButton = new QPushButton(this);
|
||
- confirmButton->setFixedSize(QSize(110, 40));
|
||
- confirmButton->setText(tr("Confirm"));
|
||
- Kiran::StylePropertyHelper::setButtonType(confirmButton, Kiran::BUTTON_Default);
|
||
- connect(confirmButton, &QPushButton::clicked, this, &IdentificationRenameDialog::onConfirmClicked);
|
||
- boxlayout->addWidget(confirmButton);
|
||
-
|
||
- boxlayout->addSpacerItem(new QSpacerItem(40, 10, QSizePolicy::Fixed, QSizePolicy::Minimum));
|
||
-
|
||
- auto cancelButton = new QPushButton(this);
|
||
- cancelButton->setFixedSize(QSize(110, 40));
|
||
- cancelButton->setText(tr("Cancel"));
|
||
- connect(cancelButton, &QPushButton::clicked, this, [this]()
|
||
- { emit completed(QPrivateSignal()); });
|
||
- boxlayout->addWidget(cancelButton);
|
||
-
|
||
- boxlayout->addStretch();
|
||
-
|
||
- layout->addLayout(boxlayout);
|
||
-
|
||
- setWindowContentWidget(container);
|
||
-}
|
||
diff --git a/plugins/authentication/src/pages/face/face-page.cpp b/plugins/authentication/src/pages/face/face-page.cpp
|
||
index 6d042e2..5e0a0db 100644
|
||
--- a/plugins/authentication/src/pages/face/face-page.cpp
|
||
+++ b/plugins/authentication/src/pages/face/face-page.cpp
|
||
@@ -65,7 +65,7 @@ QWidget* FacePage::initFeatureManagerPage()
|
||
m_featureManager->setFeatureNamePrefix(tr("face"));
|
||
m_featureManager->setDefaultDeviceLabelDesc(tr("Default face device"));
|
||
m_featureManager->setDeviceFeatureListDesc(tr("face feature list"));
|
||
- connect(m_featureManager, &GeneralBioPage::enrollFeatureClicked, this, &FacePage::onEnrollFeatureClicked);
|
||
+ connect(m_featureManager, &GeneralBioPage::enrollFeature, this, &FacePage::onEnrollFeatureClicked);
|
||
|
||
return m_featureManager;
|
||
}
|
||
diff --git a/plugins/authentication/src/pages/finger/finger-page.cpp b/plugins/authentication/src/pages/finger/finger-page.cpp
|
||
index beeb9ae..86513a6 100644
|
||
--- a/plugins/authentication/src/pages/finger/finger-page.cpp
|
||
+++ b/plugins/authentication/src/pages/finger/finger-page.cpp
|
||
@@ -14,7 +14,6 @@
|
||
|
||
#include "finger-page.h"
|
||
#include "auxiliary.h"
|
||
-#include "identification-rename-dialog.h"
|
||
#include "utils/kiran-auth-dbus-proxy.h"
|
||
#include "widgets/auth-setting-container.h"
|
||
#include "widgets/auth-setting-item.h"
|
||
@@ -90,7 +89,7 @@ QWidget* FingerPage::initFeatureManager()
|
||
m_featureManager->setFeatureNamePrefix(desc);
|
||
m_featureManager->setDefaultDeviceLabelDesc(QString(tr("Default %1 device")).arg(desc));
|
||
m_featureManager->setDeviceFeatureListDesc(QString(tr("%1 list").arg(desc)));
|
||
- connect(m_featureManager, &GeneralBioPage::enrollFeatureClicked, this, &FingerPage::onAddIdentificationClicked);
|
||
+ connect(m_featureManager, &GeneralBioPage::enrollFeature, this, &FingerPage::onAddIdentificationClicked);
|
||
return m_featureManager;
|
||
}
|
||
|
||
diff --git a/plugins/authentication/src/pages/iris/iris-page.cpp b/plugins/authentication/src/pages/iris/iris-page.cpp
|
||
index 65a3670..714c9c0 100644
|
||
--- a/plugins/authentication/src/pages/iris/iris-page.cpp
|
||
+++ b/plugins/authentication/src/pages/iris/iris-page.cpp
|
||
@@ -65,7 +65,7 @@ QWidget* IrisPage::initFeatureManagerPage()
|
||
m_featureManager->setFeatureNamePrefix(tr("iris"));
|
||
m_featureManager->setDefaultDeviceLabelDesc(tr("Default Iris device"));
|
||
m_featureManager->setDeviceFeatureListDesc(tr("Iris feature list"));
|
||
- connect(m_featureManager, &GeneralBioPage::enrollFeatureClicked, this, &IrisPage::onEnrollFeatureClicked);
|
||
+ connect(m_featureManager, &GeneralBioPage::enrollFeature, this, &IrisPage::onEnrollFeatureClicked);
|
||
|
||
return m_featureManager;
|
||
}
|
||
diff --git a/plugins/authentication/src/pages/ukey/ukey-page.cpp b/plugins/authentication/src/pages/ukey/ukey-page.cpp
|
||
index 2879d61..38051ca 100644
|
||
--- a/plugins/authentication/src/pages/ukey/ukey-page.cpp
|
||
+++ b/plugins/authentication/src/pages/ukey/ukey-page.cpp
|
||
@@ -12,7 +12,7 @@
|
||
* Author: liuxinhao <liuxinhao@kylinsec.com.cn>
|
||
*/
|
||
#include "ukey-page.h"
|
||
-#include "ukey-pin-input-dialog.h"
|
||
+#include "input-dialog/input-dialog.h"
|
||
#include "utils/kiran-auth-dbus-proxy.h"
|
||
#include "widgets/auth-setting-container.h"
|
||
#include "widgets/auth-setting-item.h"
|
||
@@ -52,7 +52,7 @@ void UKeyPage::initUI()
|
||
m_featureManager->setFeatureNamePrefix(tr("Ukey"));
|
||
m_featureManager->setDefaultDeviceLabelDesc(tr("Default Ukey device"));
|
||
m_featureManager->setDeviceFeatureListDesc(tr("List of devices bound to the Ukey"));
|
||
- connect(m_featureManager, &GeneralBioPage::enrollFeatureClicked, this, &UKeyPage::onEnrollFeatureClicked);
|
||
+ connect(m_featureManager, &GeneralBioPage::enrollFeature, this, &UKeyPage::onEnrollFeatureClicked);
|
||
|
||
mainLayout->addWidget(m_featureManager);
|
||
}
|
||
@@ -88,13 +88,16 @@ void UKeyPage::onEnrollFeatureClicked()
|
||
return;
|
||
}
|
||
|
||
- UKeyPinCodeDialog dialog;
|
||
+ InputDialog dialog;
|
||
+ dialog.setTitle(tr("UKey Enroll"));
|
||
+ dialog.setDesc(tr("Please enter the ukey pin code"));
|
||
+ dialog.setInputMode(QLineEdit::Password,32);
|
||
if (!dialog.exec())
|
||
{
|
||
return;
|
||
}
|
||
|
||
- m_pinCode = dialog.getPinCode();
|
||
+ m_pinCode = dialog.getText();
|
||
doEnroll(false);
|
||
}
|
||
|
||
diff --git a/plugins/authentication/src/widgets/general-bio-page.cpp b/plugins/authentication/src/widgets/general-bio-page.cpp
|
||
index 443f3c1..36d0ef9 100644
|
||
--- a/plugins/authentication/src/widgets/general-bio-page.cpp
|
||
+++ b/plugins/authentication/src/widgets/general-bio-page.cpp
|
||
@@ -1,7 +1,8 @@
|
||
#include "general-bio-page.h"
|
||
#include "auth-setting-container.h"
|
||
#include "auth-setting-item.h"
|
||
-#include "identification-rename-dialog.h"
|
||
+#include "checkpasswd-dialog.h"
|
||
+#include "input-dialog/input-dialog.h"
|
||
#include "utils/kiran-auth-dbus-proxy.h"
|
||
|
||
#include <kiran-message-box.h>
|
||
@@ -138,11 +139,18 @@ void GeneralBioPage::onFeatureRenameClicked()
|
||
auto iid = settingItem->getUserData().toString();
|
||
auto name = settingItem->getText();
|
||
|
||
- QScopedPointer<IdentificationRenameDialog> renameDialog(new IdentificationRenameDialog(iid, m_proxy, this));
|
||
- if (renameDialog->exec())
|
||
+ InputDialog renameDialog(this);
|
||
+ renameDialog.setTitle(tr("Rename Feature"));
|
||
+ renameDialog.setDesc(tr("Please enter the renamed feature name"));
|
||
+ renameDialog.setInputMode(QLineEdit::Normal,32);
|
||
+ if (!renameDialog.exec())
|
||
{
|
||
- refreshFeature();
|
||
+ return;
|
||
}
|
||
+
|
||
+ QString newName = renameDialog.getText();
|
||
+ m_proxy->renameIdentification(iid, newName);
|
||
+ refreshFeature();
|
||
}
|
||
|
||
void GeneralBioPage::onFeatureTrashClicked()
|
||
@@ -155,8 +163,9 @@ void GeneralBioPage::onFeatureTrashClicked()
|
||
if (m_authType == KAD_AUTH_TYPE_UKEY)
|
||
{
|
||
text = QString(tr("Are you sure you want to delete the feature called %1, "
|
||
- "Ensure that the Ukey device is inserted; "
|
||
- "otherwise the information stored in the Ukey will not be deleted")).arg(name);
|
||
+ "Ensure that the Ukey device is inserted; "
|
||
+ "otherwise the information stored in the Ukey will not be deleted"))
|
||
+ .arg(name);
|
||
}
|
||
else
|
||
{
|
||
@@ -172,6 +181,27 @@ void GeneralBioPage::onFeatureTrashClicked()
|
||
refreshFeature();
|
||
}
|
||
|
||
+void GeneralBioPage::onEnrollFeatureClicked()
|
||
+{
|
||
+ CheckpasswdDialog dialog;
|
||
+ if (!dialog.exec())
|
||
+ {
|
||
+ return;
|
||
+ }
|
||
+ dialog.hide();
|
||
+
|
||
+ auto passwd = dialog.getText();
|
||
+ if (!dialog.checkPasswd(passwd))
|
||
+ {
|
||
+ KiranMessageBox::message(this, tr("Error"),
|
||
+ tr(" Failed to enroll feature because the password verification failed!"),
|
||
+ KiranMessageBox::Ok);
|
||
+ return;
|
||
+ }
|
||
+
|
||
+ emit enrollFeature();
|
||
+}
|
||
+
|
||
void GeneralBioPage::initUI()
|
||
{
|
||
auto featureManagerLayout = new QBoxLayout(QBoxLayout::TopToBottom, this);
|
||
@@ -204,7 +234,7 @@ void GeneralBioPage::initUI()
|
||
featureManagerLayout->addWidget(addButton);
|
||
addButton->setIcon(QPixmap(":/kcp-keyboard/images/addition.svg"));
|
||
Kiran::StylePropertyHelper::setButtonType(addButton, Kiran::BUTTON_Default);
|
||
- connect(addButton, &QPushButton::clicked, this, &GeneralBioPage::enrollFeatureClicked);
|
||
+ connect(addButton, &QPushButton::clicked, this, &GeneralBioPage::onEnrollFeatureClicked);
|
||
|
||
featureManagerLayout->addStretch();
|
||
}
|
||
diff --git a/plugins/authentication/src/widgets/general-bio-page.h b/plugins/authentication/src/widgets/general-bio-page.h
|
||
index 9108dbe..fe2a0a1 100644
|
||
--- a/plugins/authentication/src/widgets/general-bio-page.h
|
||
+++ b/plugins/authentication/src/widgets/general-bio-page.h
|
||
@@ -38,13 +38,14 @@ public:
|
||
int getDeviceCount();
|
||
|
||
signals:
|
||
- void enrollFeatureClicked();
|
||
+ void enrollFeature();
|
||
|
||
private slots:
|
||
void onDefaultDeviceComboBoxCurrentIndexChanged(int idx);
|
||
void onFeatureRenameClicked();
|
||
void onFeatureTrashClicked();
|
||
-
|
||
+ void onEnrollFeatureClicked();
|
||
+
|
||
private:
|
||
void initUI();
|
||
void addFeature(const QString& featureName,const QString& featureIID);
|
||
diff --git a/plugins/authentication/translations/kiran-cpanel-authentication.zh_CN.ts b/plugins/authentication/translations/kiran-cpanel-authentication.zh_CN.ts
|
||
index afd7b5a..1856b82 100644
|
||
--- a/plugins/authentication/translations/kiran-cpanel-authentication.zh_CN.ts
|
||
+++ b/plugins/authentication/translations/kiran-cpanel-authentication.zh_CN.ts
|
||
@@ -32,6 +32,17 @@
|
||
<translation>人脸</translation>
|
||
</message>
|
||
</context>
|
||
+<context>
|
||
+ <name>CheckpasswdDialog</name>
|
||
+ <message>
|
||
+ <source>Check password</source>
|
||
+ <translation>校验当前用户密码</translation>
|
||
+ </message>
|
||
+ <message>
|
||
+ <source>Check the current password before you enroll the feature</source>
|
||
+ <translation>录入特征之前需要校验当前密码</translation>
|
||
+ </message>
|
||
+</context>
|
||
<context>
|
||
<name>DriverPage</name>
|
||
<message>
|
||
@@ -179,6 +190,14 @@
|
||
<source>tips</source>
|
||
<translation>提示</translation>
|
||
</message>
|
||
+ <message>
|
||
+ <source>Error</source>
|
||
+ <translation>错误</translation>
|
||
+ </message>
|
||
+ <message>
|
||
+ <source> Failed to enroll feature because the password verification failed!</source>
|
||
+ <translation>由于密码校验失败,录入特征失败!</translation>
|
||
+ </message>
|
||
</context>
|
||
<context>
|
||
<name>IdentificationRenameDialog</name>
|
||
@@ -192,11 +211,11 @@
|
||
</message>
|
||
<message>
|
||
<source>Confirm</source>
|
||
- <translation>确认</translation>
|
||
+ <translation type="vanished">确认</translation>
|
||
</message>
|
||
<message>
|
||
<source>Cancel</source>
|
||
- <translation>取消</translation>
|
||
+ <translation type="vanished">取消</translation>
|
||
</message>
|
||
</context>
|
||
<context>
|
||
@@ -324,11 +343,11 @@
|
||
</message>
|
||
<message>
|
||
<source>Confirm</source>
|
||
- <translation>确认</translation>
|
||
+ <translation type="vanished">确认</translation>
|
||
</message>
|
||
<message>
|
||
<source>Cancel</source>
|
||
- <translation>取消</translation>
|
||
+ <translation type="vanished">取消</translation>
|
||
</message>
|
||
</context>
|
||
</TS>
|
||
diff --git a/translations/kiran-control-panel.zh_CN.ts b/translations/kiran-control-panel.zh_CN.ts
|
||
index 96393c2..2116ffd 100644
|
||
--- a/translations/kiran-control-panel.zh_CN.ts
|
||
+++ b/translations/kiran-control-panel.zh_CN.ts
|
||
@@ -1,6 +1,19 @@
|
||
<?xml version="1.0" encoding="utf-8"?>
|
||
<!DOCTYPE TS>
|
||
<TS version="2.1" language="zh_CN">
|
||
+<context>
|
||
+ <name>InputDialog</name>
|
||
+ <message>
|
||
+ <location filename="../lib/common-widgets/input-dialog/input-dialog.cpp" line="102"/>
|
||
+ <source>Confirm</source>
|
||
+ <translation>确认</translation>
|
||
+ </message>
|
||
+ <message>
|
||
+ <location filename="../lib/common-widgets/input-dialog/input-dialog.cpp" line="111"/>
|
||
+ <source>Cancel</source>
|
||
+ <translation>取消</translation>
|
||
+ </message>
|
||
+</context>
|
||
<context>
|
||
<name>KiranModuleWidget</name>
|
||
<message>
|
||
@@ -11,6 +24,19 @@
|
||
<source>The edited content in %1 is not saved. After switching, the edited content will be lost. Are you sure you want to save?</source>
|
||
<translation type="vanished">%1中编辑的内容未保存,切换后编辑的内容将会丢失。您确定要保存吗?</translation>
|
||
</message>
|
||
+ <message>
|
||
+ <location filename="../lib/common-widgets/kiran-module-widget/kiran-module-widget.ui" line="14"/>
|
||
+ <source>Form</source>
|
||
+ <translation type="unfinished"></translation>
|
||
+ </message>
|
||
+</context>
|
||
+<context>
|
||
+ <name>KiranTips</name>
|
||
+ <message>
|
||
+ <location filename="../lib/common-widgets/kiran-tips/kiran-tips.ui" line="29"/>
|
||
+ <source>Form</source>
|
||
+ <translation type="unfinished"></translation>
|
||
+ </message>
|
||
</context>
|
||
<context>
|
||
<name>PanelWindow</name>
|
||
--
|
||
2.33.0
|
||
|