diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 765b61b9f..e465c9705 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -130,8 +130,6 @@ add_library(neochat STATIC jobs/neochatdeactivateaccountjob.h jobs/neochatdeletedevicejob.cpp jobs/neochatdeletedevicejob.h - jobs/neochatchangepasswordjob.cpp - jobs/neochatchangepasswordjob.h jobs/neochatgetcommonroomsjob.cpp jobs/neochatgetcommonroomsjob.h mediasizehelper.cpp diff --git a/src/jobs/neochatchangepasswordjob.cpp b/src/jobs/neochatchangepasswordjob.cpp deleted file mode 100644 index 4cd64e01c..000000000 --- a/src/jobs/neochatchangepasswordjob.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Tobias Fella -// SPDX-License-Identifier: GPL-2.0-or-later - -#include "neochatchangepasswordjob.h" - -using namespace Quotient; - -NeochatChangePasswordJob::NeochatChangePasswordJob(const QString &newPassword, bool logoutDevices, const std::optional &auth) - : BaseJob(HttpVerb::Post, u"ChangePasswordJob"_s, "/_matrix/client/r0/account/password") -{ - QJsonObject _data; - addParam<>(_data, u"new_password"_s, newPassword); - addParam(_data, u"logout_devices"_s, logoutDevices); - addParam(_data, u"auth"_s, auth); - setRequestData(_data); -} diff --git a/src/jobs/neochatchangepasswordjob.h b/src/jobs/neochatchangepasswordjob.h deleted file mode 100644 index 237bc4330..000000000 --- a/src/jobs/neochatchangepasswordjob.h +++ /dev/null @@ -1,12 +0,0 @@ -// SPDX-FileCopyrightText: 2023 Tobias Fella -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include - -class NeochatChangePasswordJob : public Quotient::BaseJob -{ -public: - explicit NeochatChangePasswordJob(const QString &newPassword, bool logoutDevices, const std::optional &auth = {}); -}; diff --git a/src/neochatconnection.cpp b/src/neochatconnection.cpp index b6690fc16..a001d5172 100644 --- a/src/neochatconnection.cpp +++ b/src/neochatconnection.cpp @@ -6,7 +6,6 @@ #include #include -#include "jobs/neochatchangepasswordjob.h" #include "jobs/neochatdeactivateaccountjob.h" #include "neochatconfig.h" #include "neochatroom.h" @@ -20,6 +19,7 @@ #include #include +#include #include #include #include @@ -220,18 +220,17 @@ bool NeoChatConnection::canCheckMutualRooms() const void NeoChatConnection::changePassword(const QString ¤tPassword, const QString &newPassword) { - auto job = callApi(newPassword, false); + auto job = callApi(newPassword, false); connect(job, &BaseJob::result, this, [this, job, currentPassword, newPassword] { if (job->error() == 103) { QJsonObject replyData = job->jsonData(); - QJsonObject authData; - authData["session"_L1] = replyData["session"_L1]; - authData["password"_L1] = currentPassword; - authData["type"_L1] = "m.login.password"_L1; - authData["user"_L1] = user()->id(); - QJsonObject identifier = {{"type"_L1, "m.id.user"_L1}, {"user"_L1, user()->id()}}; - authData["identifier"_L1] = identifier; - NeochatChangePasswordJob *innerJob = callApi(newPassword, false, authData); + AuthenticationData authData; + authData.session = replyData["session"_L1].toString(); + authData.type = "m.login.password"_L1; + authData.authInfo["password"_L1] = currentPassword; + authData.authInfo["user"_L1] = user()->id(); + authData.authInfo["identifier"_L1] = QJsonObject{{"type"_L1, "m.id.user"_L1}, {"user"_L1, user()->id()}}; + auto innerJob = callApi(newPassword, false, authData); connect(innerJob, &BaseJob::success, this, [this]() { Q_EMIT passwordStatus(PasswordStatus::Success); });