Verify/blacklist devices for all our accounts
This commit is contained in:
parent
b0e2533bb9
commit
7c213a5317
|
@ -360,3 +360,34 @@ class Backend:
|
|||
This should only be called from QML.
|
||||
"""
|
||||
self.models["all_rooms"].set_account_collapse(user_id, collapse)
|
||||
|
||||
|
||||
async def verify_device(
|
||||
self, user_id: str, device_id: str, ed25519_key: str,
|
||||
) -> None:
|
||||
"""Mark a device as verified on all our accounts."""
|
||||
|
||||
for client in self.clients.values():
|
||||
try:
|
||||
device = client.device_store[user_id][device_id]
|
||||
except KeyError:
|
||||
continue
|
||||
|
||||
if device.ed25519 == ed25519_key:
|
||||
client.verify_device(device)
|
||||
|
||||
|
||||
async def blacklist_device(
|
||||
self, user_id: str, device_id: str, ed25519_key: str,
|
||||
) -> None:
|
||||
"""Mark a device as blacklisted on all our accounts."""
|
||||
|
||||
for client in self.clients.values():
|
||||
try:
|
||||
# This won't include the client's current device, as expected
|
||||
device = client.device_store[user_id][device_id]
|
||||
except KeyError:
|
||||
continue
|
||||
|
||||
if device.ed25519 == ed25519_key:
|
||||
client.blacklist_device(device)
|
||||
|
|
|
@ -1371,18 +1371,6 @@ class MatrixClient(nio.AsyncClient):
|
|||
return False
|
||||
|
||||
|
||||
async def verify_device_id(self, user_id: str, device_id: str) -> None:
|
||||
"""Mark a device as verified."""
|
||||
|
||||
self.verify_device(self.device_store[user_id][device_id])
|
||||
|
||||
|
||||
async def blacklist_device_id(self, user_id: str, device_id: str) -> None:
|
||||
"""Mark a device as blacklisted."""
|
||||
|
||||
self.blacklist_device(self.device_store[user_id][device_id])
|
||||
|
||||
|
||||
async def auto_verify_all_other_accounts(self) -> None:
|
||||
"""Automatically verify/blacklist our other accounts's devices."""
|
||||
|
||||
|
|
|
@ -151,7 +151,6 @@ HTile {
|
|||
"Popups/KeyVerificationPopup.qml",
|
||||
{
|
||||
focusOnClosed: nameField,
|
||||
userId: deviceTile.userId,
|
||||
deviceOwner: deviceTile.userId,
|
||||
deviceId: model.id,
|
||||
deviceName: model.display_name,
|
||||
|
|
|
@ -9,7 +9,6 @@ HFlickableColumnPage {
|
|||
id: page
|
||||
|
||||
|
||||
property string userId
|
||||
property string deviceOwner
|
||||
property string deviceOwnerDisplayName
|
||||
property string deviceId
|
||||
|
@ -27,10 +26,9 @@ HFlickableColumnPage {
|
|||
onClicked: {
|
||||
loading = true
|
||||
|
||||
py.callClientCoro(
|
||||
userId,
|
||||
"verify_device_id",
|
||||
[deviceOwner, deviceId],
|
||||
py.callCoro(
|
||||
"verify_device",
|
||||
[deviceOwner, deviceId, ed25519Key.replace(/ /g, "")],
|
||||
() => {
|
||||
loading = false
|
||||
page.trustSet(true)
|
||||
|
@ -46,10 +44,9 @@ HFlickableColumnPage {
|
|||
onClicked: {
|
||||
loading = true
|
||||
|
||||
py.callClientCoro(
|
||||
userId,
|
||||
"blacklist_device_id",
|
||||
[deviceOwner, deviceId],
|
||||
py.callCoro(
|
||||
"blacklist_device",
|
||||
[deviceOwner, deviceId, ed25519Key.replace(/ /g, "")],
|
||||
() => {
|
||||
loading = false
|
||||
page.trustSet(false)
|
||||
|
|
|
@ -53,7 +53,6 @@ HTile {
|
|||
const item = stackView.push(
|
||||
"DeviceVerification.qml",
|
||||
{
|
||||
userId: deviceTile.userId,
|
||||
deviceOwner: deviceTile.deviceOwner,
|
||||
deviceOwnerDisplayName: deviceTile.deviceOwnerDisplayName,
|
||||
deviceId: model.id,
|
||||
|
|
|
@ -9,7 +9,6 @@ HFlickableColumnPopup {
|
|||
id: popup
|
||||
|
||||
|
||||
property string userId
|
||||
property string deviceOwner
|
||||
property string deviceId
|
||||
property string deviceName
|
||||
|
@ -27,10 +26,9 @@ HFlickableColumnPopup {
|
|||
onClicked: {
|
||||
loading = true
|
||||
|
||||
py.callClientCoro(
|
||||
userId,
|
||||
"verify_device_id",
|
||||
[deviceOwner, deviceId],
|
||||
py.callCoro(
|
||||
"verify_device",
|
||||
[deviceOwner, deviceId, ed25519Key.replace(/ /g, "")],
|
||||
() => {
|
||||
if (verifiedCallback) verifiedCallback()
|
||||
popup.close()
|
||||
|
@ -46,10 +44,9 @@ HFlickableColumnPopup {
|
|||
onClicked: {
|
||||
loading = true
|
||||
|
||||
py.callClientCoro(
|
||||
userId,
|
||||
"blacklist_device_id",
|
||||
[deviceOwner, deviceId],
|
||||
py.callCoro(
|
||||
"blacklist_device",
|
||||
[deviceOwner, deviceId, ed25519Key.replace(/ /g, "")],
|
||||
() => {
|
||||
if (blacklistedCallback) blacklistedCallback()
|
||||
popup.close()
|
||||
|
|
Loading…
Reference in New Issue
Block a user