Changeset View
Changeset View
Standalone View
Standalone View
src/ruqolacore/rocketchatmessage.cpp
Show First 20 Lines • Show All 461 Lines • ▼ Show 20 Line(s) | |||||
462 | RocketChatMessage::RocketChatMessageResult RocketChatMessage::roomFiles(const QString &roomId, quint64 id) | 462 | RocketChatMessage::RocketChatMessageResult RocketChatMessage::roomFiles(const QString &roomId, quint64 id) | ||
463 | { | 463 | { | ||
464 | const QJsonArray params{{ | 464 | const QJsonArray params{{ | ||
465 | QJsonValue(roomId) | 465 | QJsonValue(roomId) | ||
466 | }}; | 466 | }}; | ||
467 | return subscribe(QStringLiteral("roomFiles"), QJsonDocument(params), id); | 467 | return subscribe(QStringLiteral("roomFiles"), QJsonDocument(params), id); | ||
468 | } | 468 | } | ||
469 | 469 | | |||
470 | RocketChatMessage::RocketChatMessageResult RocketChatMessage::login(const QString &username, const QString &password, quint64 id) | 470 | RocketChatMessage::RocketChatMessageResult RocketChatMessage::login(const QString &username, const QString &password, const QString &twoFactorAuthenticationCode, quint64 id) | ||
471 | { | 471 | { | ||
472 | QJsonObject user; | 472 | QJsonObject user; | ||
473 | user[QStringLiteral("username")] = username; | 473 | user[QStringLiteral("username")] = username; | ||
474 | 474 | | |||
475 | QByteArray passwordAsArray = QCryptographicHash::hash(password.toUtf8(), QCryptographicHash::Sha256); | 475 | QByteArray passwordAsArray = QCryptographicHash::hash(password.toUtf8(), QCryptographicHash::Sha256); | ||
476 | const QString hash = QString::fromLatin1(passwordAsArray.toHex()); | 476 | const QString hash = QString::fromLatin1(passwordAsArray.toHex()); | ||
477 | 477 | | |||
478 | QJsonObject passwordObject; | 478 | QJsonObject passwordObject; | ||
479 | passwordObject[QStringLiteral("digest")] = hash; | 479 | passwordObject[QStringLiteral("digest")] = hash; | ||
480 | passwordObject[QStringLiteral("algorithm")] = QStringLiteral("sha-256"); | 480 | passwordObject[QStringLiteral("algorithm")] = QStringLiteral("sha-256"); | ||
481 | 481 | | |||
482 | QJsonObject params; | 482 | QJsonObject params; | ||
483 | if (!twoFactorAuthenticationCode.isEmpty()) { | ||||
mlaurent: Please add url where you find info how to generate it. | |||||
484 | // Note: This currently isn't documented. The message structure here follows the iOS client | ||||
485 | // https://github.com/RocketChat/Rocket.Chat.iOS/blob/ba49216daa50097745f15855238ef8f4d6519bcf/Rocket.Chat/Managers/Model/AuthManager/AuthManagerSocket.swift#L152 | ||||
486 | QJsonObject loginObject; | ||||
487 | loginObject[QStringLiteral("user")] = user; | ||||
488 | loginObject[QStringLiteral("password")] = passwordObject; | ||||
489 | QJsonObject totpObject; | ||||
490 | totpObject[QStringLiteral("code")] = twoFactorAuthenticationCode; | ||||
491 | totpObject[QStringLiteral("login")] = loginObject; | ||||
492 | params[QStringLiteral("totp")] = totpObject; | ||||
493 | } else { | ||||
483 | params[QStringLiteral("password")] = passwordObject; | 494 | params[QStringLiteral("password")] = passwordObject; | ||
484 | params[QStringLiteral("user")] = user; | 495 | params[QStringLiteral("user")] = user; | ||
496 | } | ||||
485 | return generateMethod(QStringLiteral("login"), QJsonDocument(params), id); | 497 | return generateMethod(QStringLiteral("login"), QJsonDocument(params), id); | ||
486 | } | 498 | } | ||
487 | 499 | | |||
488 | RocketChatMessage::RocketChatMessageResult RocketChatMessage::loginProvider(const QString &credentialToken, const QString &credentialSecretd, quint64 id) | 500 | RocketChatMessage::RocketChatMessageResult RocketChatMessage::loginProvider(const QString &credentialToken, const QString &credentialSecretd, quint64 id) | ||
489 | { | 501 | { | ||
490 | QJsonObject params; | 502 | QJsonObject params; | ||
491 | QJsonObject authKeys; | 503 | QJsonObject authKeys; | ||
492 | authKeys[QStringLiteral("credentialToken")] = credentialToken; | 504 | authKeys[QStringLiteral("credentialToken")] = credentialToken; | ||
▲ Show 20 Lines • Show All 145 Lines • Show Last 20 Lines |
Please add url where you find info how to generate it.