Implement session sign out (password auth only)

This commit is contained in:
miruka
2020-06-29 10:30:44 -04:00
parent 8a3d9affaa
commit b47d4d981f
7 changed files with 85 additions and 32 deletions

View File

@@ -53,16 +53,32 @@ HColumnPage {
}
function deleteDevices(...indice) {
const deviceIds = []
if (indice.length === 1 && indice[0] === 0) {
utils.makePopup("Popups/SignOutPopup.qml", { userId: page.userId })
return
}
for (const i of indice.sort())
const deviceIds = []
let deleteOwnDevice = false
for (const i of indice.sort()) {
i === 0 ?
deleteOwnDevice = true :
deviceIds.push(deviceList.model.get(i).id)
}
utils.makePopup(
"Popups/AuthentificationPopup.qml",
"Popups/DeleteDevicesPopup.qml",
{
userId: page.userId,
deviceIds,
deletedCallback: () => {
deleteOwnDevice ?
utils.makePopup(
"Popups/SignOutPopup.qml", { userId: page.userId },
) :
page.loadDevices()
},
},
)
}

View File

@@ -1,25 +0,0 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
import QtQuick 2.12
import "../Base"
import "../Base/ButtonLayout"
HFlickableColumnPopup {
id: popup
property string userId
property string deviceIds
page.footer: ButtonLayout {
CancelButton {
id: cancelButton
onClicked: popup.close()
}
}
onOpened: cancelButton.forceActiveFocus()
SummaryLabel { text: qsTr("Not implemented yet") }
}

View File

@@ -0,0 +1,40 @@
// SPDX-License-Identifier: LGPL-3.0-or-later
import QtQuick 2.12
import "../Base"
import "../Base/ButtonLayout"
PasswordPopup {
id: popup
property string userId
property var deviceIds // array
property var deletedCallback: null
function verifyPassword(pass, callback) {
py.callClientCoro(
userId,
"delete_devices_with_password",
[deviceIds, pass],
() => callback(true),
(type, args) => {
callback(
type === "MatrixUnauthorized" ?
false :
qsTr("Unknown error: %1 - %2").arg(type).arg(args)
)
},
)
}
summary.text:
qsTr("Enter your account's password to continue:")
validateButton.text: qsTr("Sign out")
validateButton.icon.name: "sign-out"
onClosed: if (acceptedPassword && deletedCallback) deletedCallback()
}