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.
|
This should only be called from QML.
|
||||||
"""
|
"""
|
||||||
self.models["all_rooms"].set_account_collapse(user_id, collapse)
|
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
|
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:
|
async def auto_verify_all_other_accounts(self) -> None:
|
||||||
"""Automatically verify/blacklist our other accounts's devices."""
|
"""Automatically verify/blacklist our other accounts's devices."""
|
||||||
|
|
||||||
|
|
|
@ -151,7 +151,6 @@ HTile {
|
||||||
"Popups/KeyVerificationPopup.qml",
|
"Popups/KeyVerificationPopup.qml",
|
||||||
{
|
{
|
||||||
focusOnClosed: nameField,
|
focusOnClosed: nameField,
|
||||||
userId: deviceTile.userId,
|
|
||||||
deviceOwner: deviceTile.userId,
|
deviceOwner: deviceTile.userId,
|
||||||
deviceId: model.id,
|
deviceId: model.id,
|
||||||
deviceName: model.display_name,
|
deviceName: model.display_name,
|
||||||
|
|
|
@ -9,7 +9,6 @@ HFlickableColumnPage {
|
||||||
id: page
|
id: page
|
||||||
|
|
||||||
|
|
||||||
property string userId
|
|
||||||
property string deviceOwner
|
property string deviceOwner
|
||||||
property string deviceOwnerDisplayName
|
property string deviceOwnerDisplayName
|
||||||
property string deviceId
|
property string deviceId
|
||||||
|
@ -27,10 +26,9 @@ HFlickableColumnPage {
|
||||||
onClicked: {
|
onClicked: {
|
||||||
loading = true
|
loading = true
|
||||||
|
|
||||||
py.callClientCoro(
|
py.callCoro(
|
||||||
userId,
|
"verify_device",
|
||||||
"verify_device_id",
|
[deviceOwner, deviceId, ed25519Key.replace(/ /g, "")],
|
||||||
[deviceOwner, deviceId],
|
|
||||||
() => {
|
() => {
|
||||||
loading = false
|
loading = false
|
||||||
page.trustSet(true)
|
page.trustSet(true)
|
||||||
|
@ -46,10 +44,9 @@ HFlickableColumnPage {
|
||||||
onClicked: {
|
onClicked: {
|
||||||
loading = true
|
loading = true
|
||||||
|
|
||||||
py.callClientCoro(
|
py.callCoro(
|
||||||
userId,
|
"blacklist_device",
|
||||||
"blacklist_device_id",
|
[deviceOwner, deviceId, ed25519Key.replace(/ /g, "")],
|
||||||
[deviceOwner, deviceId],
|
|
||||||
() => {
|
() => {
|
||||||
loading = false
|
loading = false
|
||||||
page.trustSet(false)
|
page.trustSet(false)
|
||||||
|
|
|
@ -53,7 +53,6 @@ HTile {
|
||||||
const item = stackView.push(
|
const item = stackView.push(
|
||||||
"DeviceVerification.qml",
|
"DeviceVerification.qml",
|
||||||
{
|
{
|
||||||
userId: deviceTile.userId,
|
|
||||||
deviceOwner: deviceTile.deviceOwner,
|
deviceOwner: deviceTile.deviceOwner,
|
||||||
deviceOwnerDisplayName: deviceTile.deviceOwnerDisplayName,
|
deviceOwnerDisplayName: deviceTile.deviceOwnerDisplayName,
|
||||||
deviceId: model.id,
|
deviceId: model.id,
|
||||||
|
|
|
@ -9,7 +9,6 @@ HFlickableColumnPopup {
|
||||||
id: popup
|
id: popup
|
||||||
|
|
||||||
|
|
||||||
property string userId
|
|
||||||
property string deviceOwner
|
property string deviceOwner
|
||||||
property string deviceId
|
property string deviceId
|
||||||
property string deviceName
|
property string deviceName
|
||||||
|
@ -27,10 +26,9 @@ HFlickableColumnPopup {
|
||||||
onClicked: {
|
onClicked: {
|
||||||
loading = true
|
loading = true
|
||||||
|
|
||||||
py.callClientCoro(
|
py.callCoro(
|
||||||
userId,
|
"verify_device",
|
||||||
"verify_device_id",
|
[deviceOwner, deviceId, ed25519Key.replace(/ /g, "")],
|
||||||
[deviceOwner, deviceId],
|
|
||||||
() => {
|
() => {
|
||||||
if (verifiedCallback) verifiedCallback()
|
if (verifiedCallback) verifiedCallback()
|
||||||
popup.close()
|
popup.close()
|
||||||
|
@ -46,10 +44,9 @@ HFlickableColumnPopup {
|
||||||
onClicked: {
|
onClicked: {
|
||||||
loading = true
|
loading = true
|
||||||
|
|
||||||
py.callClientCoro(
|
py.callCoro(
|
||||||
userId,
|
"blacklist_device",
|
||||||
"blacklist_device_id",
|
[deviceOwner, deviceId, ed25519Key.replace(/ /g, "")],
|
||||||
[deviceOwner, deviceId],
|
|
||||||
() => {
|
() => {
|
||||||
if (blacklistedCallback) blacklistedCallback()
|
if (blacklistedCallback) blacklistedCallback()
|
||||||
popup.close()
|
popup.close()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user