From 2b79de2087565c75833341a26ea16215fc5912a0 Mon Sep 17 00:00:00 2001 From: Alexander-Porter Date: Wed, 10 Jul 2024 14:47:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86User=E7=B1=BB?= =?UTF-8?q?=E7=9A=84=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mainwindow.cpp | 1 + modifyinfor_win.cpp | 4 +++- user.cpp | 14 ++++++++++++-- user.h | 2 +- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 6d747d8..e079fa5 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -211,6 +211,7 @@ void MainWindow::onUserLoggedIn(User user) CurrentUser=new User(user); connect(CurrentUser->channel,&MessageChannel::message,this,&MainWindow::onMessage); _userinfopage->currentUser=CurrentUser; + _modifyInfor_win->currentUser=CurrentUser; db->insertUser(user.getEmail(),user.gethashedPassword()); setUserInfoCardTitle(user.getUsername()); setUserInfoCardSubTitle(user.getEmail()); diff --git a/modifyinfor_win.cpp b/modifyinfor_win.cpp index 34783b1..d84be74 100644 --- a/modifyinfor_win.cpp +++ b/modifyinfor_win.cpp @@ -107,7 +107,9 @@ void modifyInfor_win::onConfirmButtonClicked() QMessageBox::warning(this, "错误", "两次输入的密码不一致。"); return; } - + currentUser->username = newId; + currentUser->hashedPassword = newPassword; + currentUser->updateUser(); // 更新数据库 emit changexinxi(User(*currentUser)); diff --git a/user.cpp b/user.cpp index 47b2ae6..8f2bedc 100644 --- a/user.cpp +++ b/user.cpp @@ -306,7 +306,17 @@ bool User::getisLogin() // return session; }*/ -bool User::updateUser(User &user) +bool User::updateUser() { - return true; + QString postData = QString("username=%1&password=%2").arg(this->username).arg(this->hashedPassword); + ApiResponse response = apiRequest->post("/updateInfo", postData.toUtf8()); + if (response.isSuccess()) + { + return true; + } + else + { + emit channel->message(response.message, "Error"); + return false; + } } diff --git a/user.h b/user.h index a007a67..d7bb82c 100644 --- a/user.h +++ b/user.h @@ -47,7 +47,7 @@ class User : public QObject TaskToken getTaskToken(int id);//获取tasktoken TaskToken getTaskTokenByRemote(QString s3Dir); bool logout();//登出 - bool updateUser(User &user); + bool updateUser(); QString getS3Location();//获取云端容器地址 QString getUsername();//获取用户名 QString getEmail();//获取用户邮箱