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:
@@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user