aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/definitions/auth_data.h
diff options
context:
space:
mode:
authorn-peugnet <n.peugnet@free.fr>2022-10-06 19:27:24 +0200
committern-peugnet <n.peugnet@free.fr>2022-10-06 19:27:24 +0200
commitd911b207f49e936b3e992200796110f0749ed150 (patch)
tree96d20ebb4d074a4c1755e21cb316a52d584daee3 /lib/csapi/definitions/auth_data.h
parent8ad8a74152c5701b6ca1f9a00487ba9257a439b4 (diff)
parent56c2f2e2b809b9077393eb617828f33d144f5634 (diff)
downloadlibquotient-d911b207f49e936b3e992200796110f0749ed150.tar.gz
libquotient-d911b207f49e936b3e992200796110f0749ed150.zip
New upstream version 0.7.0
Diffstat (limited to 'lib/csapi/definitions/auth_data.h')
-rw-r--r--lib/csapi/definitions/auth_data.h54
1 files changed, 31 insertions, 23 deletions
diff --git a/lib/csapi/definitions/auth_data.h b/lib/csapi/definitions/auth_data.h
index 661d3e5f..a9972323 100644
--- a/lib/csapi/definitions/auth_data.h
+++ b/lib/csapi/definitions/auth_data.h
@@ -6,29 +6,37 @@
#include "converters.h"
-#include <QtCore/QJsonObject>
-#include <QtCore/QHash>
-
-namespace QMatrixClient
-{
- // Data structures
-
- /// Used by clients to submit authentication information to the interactive-authentication API
- struct AuthenticationData
+namespace Quotient {
+/// Used by clients to submit authentication information to the
+/// interactive-authentication API
+struct AuthenticationData {
+ /// The authentication type that the client is attempting to complete.
+ /// May be omitted if `session` is given, and the client is reissuing a
+ /// request which it believes has been completed out-of-band (for example,
+ /// via the [fallback mechanism](#fallback)).
+ QString type;
+
+ /// The value of the session key given by the homeserver.
+ QString session;
+
+ /// Keys dependent on the login type
+ QHash<QString, QJsonObject> authInfo;
+};
+
+template <>
+struct JsonObjectConverter<AuthenticationData> {
+ static void dumpTo(QJsonObject& jo, const AuthenticationData& pod)
{
- /// The login type that the client is attempting to complete.
- QString type;
- /// The value of the session key given by the homeserver.
- QString session;
- /// Keys dependent on the login type
- QHash<QString, QJsonObject> authInfo;
- };
-
- QJsonObject toJson(const AuthenticationData& pod);
-
- template <> struct FromJsonObject<AuthenticationData>
+ fillJson(jo, pod.authInfo);
+ addParam<IfNotEmpty>(jo, QStringLiteral("type"), pod.type);
+ addParam<IfNotEmpty>(jo, QStringLiteral("session"), pod.session);
+ }
+ static void fillFrom(QJsonObject jo, AuthenticationData& pod)
{
- AuthenticationData operator()(QJsonObject jo) const;
- };
+ fromJson(jo.take("type"_ls), pod.type);
+ fromJson(jo.take("session"_ls), pod.session);
+ fromJson(jo, pod.authInfo);
+ }
+};
-} // namespace QMatrixClient
+} // namespace Quotient