Make it easier to understand, what button to click for verification from profile

This commit is contained in:
Nicolas Werner 2021-01-12 14:49:15 +01:00
parent 81762119b9
commit 31881e14d9
5 changed files with 41 additions and 10 deletions

View File

@ -61,10 +61,18 @@ ApplicationWindow {
text: qsTr("Verify") text: qsTr("Verify")
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
enabled: !profile.isUserVerified enabled: !profile.isUserVerified
visible: !profile.isUserVerified visible: !profile.isUserVerified && !profile.isSelf && profile.userVerificationEnabled
onClicked: profile.verify() onClicked: profile.verify()
} }
Image {
Layout.preferredHeight: 16
Layout.preferredWidth: 16
source: "image://colorimage/:/icons/icons/ui/lock.png?green"
visible: profile.isUserVerified
Layout.alignment: Qt.AlignHCenter
}
RowLayout { RowLayout {
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
spacing: 8 spacing: 8
@ -153,6 +161,7 @@ ApplicationWindow {
Button { Button {
id: verifyButton id: verifyButton
visible: (!profile.userVerificationEnabled && !profile.isSelf) || (profile.isSelf && (model.verificationStatus != VerificationStatus.VERIFIED || !profile.userVerificationEnabled))
text: (model.verificationStatus != VerificationStatus.VERIFIED) ? "Verify" : "Unverify" text: (model.verificationStatus != VerificationStatus.VERIFIED) ? "Verify" : "Unverify"
onClicked: { onClicked: {
if (model.verificationStatus == VerificationStatus.VERIFIED) if (model.verificationStatus == VerificationStatus.VERIFIED)

View File

@ -10,6 +10,8 @@ Pane {
spacing: 16 spacing: 16
Label { Label {
// Self verification
Layout.maximumWidth: 400 Layout.maximumWidth: 400
Layout.fillHeight: true Layout.fillHeight: true
Layout.fillWidth: true Layout.fillWidth: true
@ -21,14 +23,12 @@ Pane {
else else
return qsTr("To ensure that no malicious user can eavesdrop on your encrypted communications you can verify the other party."); return qsTr("To ensure that no malicious user can eavesdrop on your encrypted communications you can verify the other party.");
} else { } else {
// Self verification
if (!flow.isSelfVerification && flow.isDeviceVerification) if (!flow.isSelfVerification && flow.isDeviceVerification)
return qsTr("%1 has requested to verify their device %2.").arg(flow.userId).arg(flow.deviceId); return qsTr("%1 has requested to verify their device %2.").arg(flow.userId).arg(flow.deviceId);
else if (!flow.isSelfVerification && !flow.isDeviceVerification) else if (!flow.isSelfVerification && !flow.isDeviceVerification)
return qsTr("%1 using the device %2 has requested to be verified.").arg(flow.userId).arg(flow.deviceId); return qsTr("%1 using the device %2 has requested to be verified.").arg(flow.userId).arg(flow.deviceId);
else else
return qsTr("Your devices (%1) has requested to be verified.").arg(flow.deviceId); return qsTr("Your device (%1) has requested to be verified.").arg(flow.deviceId);
} }
} }
color: colors.text color: colors.text

View File

@ -360,27 +360,35 @@ EventStore::handle_room_verification(mtx::events::collections::TimelineEvents ev
std::visit( std::visit(
overloaded{ overloaded{
[this](const mtx::events::RoomEvent<mtx::events::msg::KeyVerificationRequest> &msg) { [this](const mtx::events::RoomEvent<mtx::events::msg::KeyVerificationRequest> &msg) {
nhlog::db()->debug("handle_room_verification: Request");
emit startDMVerification(msg); emit startDMVerification(msg);
}, },
[](const mtx::events::RoomEvent<mtx::events::msg::KeyVerificationCancel> &msg) { [](const mtx::events::RoomEvent<mtx::events::msg::KeyVerificationCancel> &msg) {
nhlog::db()->debug("handle_room_verification: Cancel");
ChatPage::instance()->receivedDeviceVerificationCancel(msg.content); ChatPage::instance()->receivedDeviceVerificationCancel(msg.content);
}, },
[](const mtx::events::RoomEvent<mtx::events::msg::KeyVerificationAccept> &msg) { [](const mtx::events::RoomEvent<mtx::events::msg::KeyVerificationAccept> &msg) {
nhlog::db()->debug("handle_room_verification: Accept");
ChatPage::instance()->receivedDeviceVerificationAccept(msg.content); ChatPage::instance()->receivedDeviceVerificationAccept(msg.content);
}, },
[](const mtx::events::RoomEvent<mtx::events::msg::KeyVerificationKey> &msg) { [](const mtx::events::RoomEvent<mtx::events::msg::KeyVerificationKey> &msg) {
nhlog::db()->debug("handle_room_verification: Key");
ChatPage::instance()->receivedDeviceVerificationKey(msg.content); ChatPage::instance()->receivedDeviceVerificationKey(msg.content);
}, },
[](const mtx::events::RoomEvent<mtx::events::msg::KeyVerificationMac> &msg) { [](const mtx::events::RoomEvent<mtx::events::msg::KeyVerificationMac> &msg) {
nhlog::db()->debug("handle_room_verification: Mac");
ChatPage::instance()->receivedDeviceVerificationMac(msg.content); ChatPage::instance()->receivedDeviceVerificationMac(msg.content);
}, },
[](const mtx::events::RoomEvent<mtx::events::msg::KeyVerificationReady> &msg) { [](const mtx::events::RoomEvent<mtx::events::msg::KeyVerificationReady> &msg) {
nhlog::db()->debug("handle_room_verification: Ready");
ChatPage::instance()->receivedDeviceVerificationReady(msg.content); ChatPage::instance()->receivedDeviceVerificationReady(msg.content);
}, },
[](const mtx::events::RoomEvent<mtx::events::msg::KeyVerificationDone> &msg) { [](const mtx::events::RoomEvent<mtx::events::msg::KeyVerificationDone> &msg) {
nhlog::db()->debug("handle_room_verification: Done");
ChatPage::instance()->receivedDeviceVerificationDone(msg.content); ChatPage::instance()->receivedDeviceVerificationDone(msg.content);
}, },
[](const mtx::events::RoomEvent<mtx::events::msg::KeyVerificationStart> &msg) { [](const mtx::events::RoomEvent<mtx::events::msg::KeyVerificationStart> &msg) {
nhlog::db()->debug("handle_room_verification: Start");
ChatPage::instance()->receivedDeviceVerificationStart(msg.content, msg.sender); ChatPage::instance()->receivedDeviceVerificationStart(msg.content, msg.sender);
}, },
[](const auto &) {}, [](const auto &) {},

View File

@ -112,6 +112,17 @@ UserProfile::getUserStatus()
return isUserVerified; return isUserVerified;
} }
bool
UserProfile::userVerificationEnabled() const
{
return hasMasterKey;
}
bool
UserProfile::isSelf() const
{
return this->userid_ == utils::localUser();
}
void void
UserProfile::fetchDeviceList(const QString &userID) UserProfile::fetchDeviceList(const QString &userID)
{ {
@ -128,10 +139,10 @@ UserProfile::fetchDeviceList(const QString &userID)
return; return;
} }
// Finding if the User is Verified or not based on the Signatures // Ensure local key cache is up to date
cache::client()->query_keys( cache::client()->query_keys(
utils::localUser().toStdString(), utils::localUser().toStdString(),
[other_user_id, other_user_keys, this](const UserKeyCache &res, [other_user_id, other_user_keys, this](const UserKeyCache &,
mtx::http::RequestErr err) { mtx::http::RequestErr err) {
using namespace mtx; using namespace mtx;
std::string local_user_id = utils::localUser().toStdString(); std::string local_user_id = utils::localUser().toStdString();
@ -143,10 +154,7 @@ UserProfile::fetchDeviceList(const QString &userID)
return; return;
} }
if (res.device_keys.empty()) { this->hasMasterKey = !other_user_keys.master_keys.keys.empty();
nhlog::net()->warn("no devices retrieved {}", local_user_id);
return;
}
std::vector<DeviceInfo> deviceInfo; std::vector<DeviceInfo> deviceInfo;
auto devices = other_user_keys.device_keys; auto devices = other_user_keys.device_keys;

View File

@ -84,6 +84,9 @@ class UserProfile : public QObject
Q_PROPERTY(QString avatarUrl READ avatarUrl CONSTANT) Q_PROPERTY(QString avatarUrl READ avatarUrl CONSTANT)
Q_PROPERTY(DeviceInfoModel *deviceList READ deviceList CONSTANT) Q_PROPERTY(DeviceInfoModel *deviceList READ deviceList CONSTANT)
Q_PROPERTY(bool isUserVerified READ getUserStatus NOTIFY userStatusChanged) Q_PROPERTY(bool isUserVerified READ getUserStatus NOTIFY userStatusChanged)
Q_PROPERTY(
bool userVerificationEnabled READ userVerificationEnabled NOTIFY userStatusChanged)
Q_PROPERTY(bool isSelf READ isSelf CONSTANT)
public: public:
UserProfile(QString roomid, UserProfile(QString roomid,
QString userid, QString userid,
@ -96,6 +99,8 @@ public:
QString displayName(); QString displayName();
QString avatarUrl(); QString avatarUrl();
bool getUserStatus(); bool getUserStatus();
bool userVerificationEnabled() const;
bool isSelf() const;
Q_INVOKABLE void verify(QString device = ""); Q_INVOKABLE void verify(QString device = "");
Q_INVOKABLE void unverify(QString device = ""); Q_INVOKABLE void unverify(QString device = "");
@ -112,6 +117,7 @@ private:
QString roomid_, userid_; QString roomid_, userid_;
DeviceInfoModel deviceList_; DeviceInfoModel deviceList_;
bool isUserVerified = false; bool isUserVerified = false;
bool hasMasterKey = false;
TimelineViewManager *manager; TimelineViewManager *manager;
TimelineModel *model; TimelineModel *model;
}; };