Merge pull request #4174 from matrix-org/bwindels/showverifyifuserhasxsignkeys
only show verify button if user has uploaded cross-signing keys
This commit is contained in:
commit
5df35ea432
1 changed files with 36 additions and 14 deletions
|
@ -136,6 +136,23 @@ function useIsEncrypted(cli, room) {
|
||||||
return isEncrypted;
|
return isEncrypted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function useHasCrossSigningKeys(cli, member, canVerify, setUpdating) {
|
||||||
|
return useAsyncMemo(async () => {
|
||||||
|
if (!canVerify) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
setUpdating(true);
|
||||||
|
try {
|
||||||
|
await cli.downloadKeys([member.userId]);
|
||||||
|
const xsi = cli.getStoredCrossSigningForUser(member.userId);
|
||||||
|
const key = xsi && xsi.getId();
|
||||||
|
return !!key;
|
||||||
|
} finally {
|
||||||
|
setUpdating(false);
|
||||||
|
}
|
||||||
|
}, [cli, member, canVerify], false);
|
||||||
|
}
|
||||||
|
|
||||||
async function verifyDevice(userId, device) {
|
async function verifyDevice(userId, device) {
|
||||||
const cli = MatrixClientPeg.get();
|
const cli = MatrixClientPeg.get();
|
||||||
const member = cli.getUser(userId);
|
const member = cli.getUser(userId);
|
||||||
|
@ -1324,22 +1341,27 @@ const BasicUserInfo = ({room, member, groupId, devices, isRoomEncrypted}) => {
|
||||||
|
|
||||||
let verifyButton;
|
let verifyButton;
|
||||||
const homeserverSupportsCrossSigning = useHomeserverSupportsCrossSigning(cli);
|
const homeserverSupportsCrossSigning = useHomeserverSupportsCrossSigning(cli);
|
||||||
if (
|
|
||||||
SettingsStore.isFeatureEnabled("feature_cross_signing") &&
|
|
||||||
homeserverSupportsCrossSigning
|
|
||||||
) {
|
|
||||||
const userTrust = cli.checkUserTrust(member.userId);
|
const userTrust = cli.checkUserTrust(member.userId);
|
||||||
const userVerified = userTrust.isCrossSigningVerified();
|
const userVerified = userTrust.isCrossSigningVerified();
|
||||||
const isMe = member.userId === cli.getUserId();
|
const isMe = member.userId === cli.getUserId();
|
||||||
|
const canVerify = SettingsStore.isFeatureEnabled("feature_cross_signing") &&
|
||||||
|
homeserverSupportsCrossSigning &&
|
||||||
|
isRoomEncrypted && !userVerified && !isMe;
|
||||||
|
|
||||||
if (isRoomEncrypted && !userVerified && !isMe) {
|
const setUpdating = (updating) => {
|
||||||
|
setPendingUpdateCount(count => count + (updating ? 1 : -1));
|
||||||
|
};
|
||||||
|
const hasCrossSigningKeys =
|
||||||
|
useHasCrossSigningKeys(cli, member, canVerify, setUpdating );
|
||||||
|
|
||||||
|
if (canVerify && hasCrossSigningKeys) {
|
||||||
verifyButton = (
|
verifyButton = (
|
||||||
<AccessibleButton className="mx_UserInfo_field" onClick={() => verifyUser(member)}>
|
<AccessibleButton className="mx_UserInfo_field" onClick={() => verifyUser(member)}>
|
||||||
{_t("Verify")}
|
{_t("Verify")}
|
||||||
</AccessibleButton>
|
</AccessibleButton>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
let devicesSection;
|
let devicesSection;
|
||||||
if (isRoomEncrypted) {
|
if (isRoomEncrypted) {
|
||||||
|
|
Loading…
Reference in a new issue