1
0

Add @auth_protect decorator.

This guards function calls by storing the function, args and kwargs into
an added attribute '__auth_fcall' on the object using the decorator,
then emits a signal that can be handled by the UI.

The UI can signal auth-success or auth-failure back to the object by
calling either the authProceed() slot or the authCancel slot.

The object utilizing this decorator MUST inherit/mixin the AuthMixin
class, which provides the above two slots, and handling of state.

The decorator also accepts a 'reject' parameter, containing the name of
a parameterless function on the object, which is called when
authentication has failed/is cancelled.
This commit is contained in:
Sander van Grieken
2022-06-15 22:41:33 +02:00
parent 0b8de89e66
commit 7cb8c347b5
4 changed files with 87 additions and 4 deletions

View File

@@ -221,4 +221,18 @@ ApplicationWindow
notificationPopup.show(message)
}
}
Connections {
target: Daemon.currentWallet
function onAuthRequired() {
var dialog = app.messageDialog.createObject(app, {'text': 'Auth placeholder', 'yesno': true})
dialog.yesClicked.connect(function() {
Daemon.currentWallet.authProceed()
})
dialog.noClicked.connect(function() {
Daemon.currentWallet.authCancel()
})
dialog.open()
}
}
}