From f7a300b89b8251119202f99fd7c40193b64a3dcd Mon Sep 17 00:00:00 2001 From: Sander van Grieken Date: Thu, 9 Mar 2023 10:19:17 +0100 Subject: [PATCH] qml: successful PIN entry stays valid for 5 mins --- electrum/gui/qml/components/main.qml | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/electrum/gui/qml/components/main.qml b/electrum/gui/qml/components/main.qml index f17cdd375..9505a8914 100644 --- a/electrum/gui/qml/components/main.qml +++ b/electrum/gui/qml/components/main.qml @@ -485,6 +485,9 @@ ApplicationWindow } } + property var _lastCorrectPinTime: 0 + property int _pinValidSeconds: 5*60 + function handleAuthRequired(qtobject, method) { console.log('auth using method ' + method) if (method == 'wallet') { @@ -510,8 +513,14 @@ ApplicationWindow // no PIN configured qtobject.authProceed() } else { + if (Date.now() - _lastCorrectPinTime > _pinValidSeconds * 1000) { + // correct pin entered recently, accept. + qtobject.authProceed() + return + } var dialog = app.pinDialog.createObject(app, {mode: 'check', pincode: Config.pinCode}) dialog.accepted.connect(function() { + _lastCorrectPinTime = Date.now() qtobject.authProceed() dialog.close() }) @@ -527,21 +536,22 @@ ApplicationWindow } property var _lastActive: 0 // record time of last activity - property int _maxInactive: 30 // seconds property bool _lockDialogShown: false onActiveChanged: { console.log('app active = ' + active) - if (!active) { - // deactivated - _lastActive = Date.now() - } else { + if (active) { + if (!_lastActive) { + _lastActive = Date.now() + return + } // activated - if (_lastActive != 0 && Date.now() - _lastActive > _maxInactive * 1000) { + if (Date.now() - _lastCorrectPinTime > _pinValidSeconds * 1000) { if (_lockDialogShown || Config.pinCode == '') return var dialog = app.pinDialog.createObject(app, {mode: 'check', canCancel: false, pincode: Config.pinCode}) dialog.accepted.connect(function() { + _lastCorrectPinTime = Date.now() dialog.close() _lockDialogShown = false })