diff --git a/mainwindow.cpp b/mainwindow.cpp index 4564fe3..cabec25 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 0fdbd06..7e5fd96 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)); currentUser->username = newId; 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();//获取用户邮箱