Reset account password
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
#include "models/User.h"
|
||||
#include "components/SlidePickerBox.h"
|
||||
#include "SelectDialog.h"
|
||||
#include "AlertDialog.h"
|
||||
|
||||
AccountFormDialog::AccountFormDialog(QWidget *parent,AccountEditMode mode, Qt::WindowFlags f) : GUIFormBaseDialog(parent, f) {
|
||||
m_mode = mode;
|
||||
@@ -119,6 +120,29 @@ AccountFormDialog::AccountFormDialog(QWidget *parent,AccountEditMode mode, Qt::W
|
||||
btn_Role->setText("doctor");
|
||||
m_RoleID = User::getRoleID("doctor");
|
||||
}
|
||||
else{
|
||||
connect(btn_Pwd,&QAbstractButton::clicked,[=](){
|
||||
AlertDialog dialog(this);
|
||||
dialog.setButtonMode(OkAndCancel);
|
||||
dialog.setWindowModality(Qt::WindowModal);
|
||||
dialog.setAlertMessage(tr("Reset password to \"123456\" ?"));
|
||||
if (dialog.exec() == Accepted)
|
||||
{
|
||||
User user;
|
||||
dialog.setButtonMode(OkOnly);
|
||||
if (!User::getUser(m_UserID, user)) {
|
||||
dialog.setAlertMessage(tr("Inner error, can't find reference user!"));
|
||||
dialog.exec();
|
||||
return;
|
||||
}
|
||||
if (!user.resetPassword())
|
||||
{
|
||||
dialog.setAlertMessage(tr("Submit change to database fail!"));
|
||||
dialog.exec();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
connect(btn_Role,&QAbstractButton::clicked,[=](){
|
||||
SelectDialog selectDialog(this);
|
||||
selectDialog.setAvailableDates(User::getAllRoleName());
|
||||
@@ -199,7 +223,7 @@ bool AccountFormDialog::updateReferenceData() {
|
||||
user.setUserName(m_NewUserName);
|
||||
}
|
||||
if (this->roleChanged) user.setRoleID(m_RoleID);
|
||||
if (!this->commentChanged) user.setUserName(le_Comment->text());
|
||||
if (!this->commentChanged) user.setComment(le_Comment->text());
|
||||
bool ret = user.submitChange();
|
||||
if (ret) {
|
||||
LOG_USER_OPERATION(AdminChangeAcountInformation);
|
||||
@@ -238,23 +262,23 @@ bool AccountFormDialog::updateReferenceData() {
|
||||
refmodel->insertRow(0);
|
||||
refmodel->setData(refmodel->index(0, 0), QUuid::createUuid().toString());
|
||||
refmodel->setData(refmodel->index(0, 1), le_UserCode->text());
|
||||
#define USER_READONLY_PROPERTY(name) name,
|
||||
#define USER_PROPERTY(name)\
|
||||
#define USER_READONLY_PROPERTY(name) name,
|
||||
#define USER_PROPERTY(name)\
|
||||
USER_READONLY_PROPERTY(name)
|
||||
|
||||
enum user_index {
|
||||
USER_PROPERTIES_MACRO()
|
||||
};
|
||||
#undef USER_READONLY_PROPERTY
|
||||
#undef USER_PROPERTY
|
||||
#undef USER_READONLY_PROPERTY
|
||||
#undef USER_PROPERTY
|
||||
|
||||
#define USER_READONLY_PROPERTY(name)
|
||||
#define USER_PROPERTY(name)\
|
||||
#define USER_READONLY_PROPERTY(name)
|
||||
#define USER_PROPERTY(name)\
|
||||
USER_READONLY_PROPERTY(name)\
|
||||
refmodel->setData(refmodel->index(0, name),user.get##name());
|
||||
USER_PROPERTIES_MACRO()
|
||||
#undef USER_READONLY_PROPERTY
|
||||
#undef USER_PROPERTY
|
||||
#undef USER_READONLY_PROPERTY
|
||||
#undef USER_PROPERTY
|
||||
|
||||
if (refmodel->submit()) {
|
||||
hideWarn();
|
||||
|
||||
Reference in New Issue
Block a user