qml: successful PIN entry stays valid for 5 mins
This commit is contained in:
@@ -485,6 +485,9 @@ ApplicationWindow
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
property var _lastCorrectPinTime: 0
|
||||||
|
property int _pinValidSeconds: 5*60
|
||||||
|
|
||||||
function handleAuthRequired(qtobject, method) {
|
function handleAuthRequired(qtobject, method) {
|
||||||
console.log('auth using method ' + method)
|
console.log('auth using method ' + method)
|
||||||
if (method == 'wallet') {
|
if (method == 'wallet') {
|
||||||
@@ -510,8 +513,14 @@ ApplicationWindow
|
|||||||
// no PIN configured
|
// no PIN configured
|
||||||
qtobject.authProceed()
|
qtobject.authProceed()
|
||||||
} else {
|
} 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})
|
var dialog = app.pinDialog.createObject(app, {mode: 'check', pincode: Config.pinCode})
|
||||||
dialog.accepted.connect(function() {
|
dialog.accepted.connect(function() {
|
||||||
|
_lastCorrectPinTime = Date.now()
|
||||||
qtobject.authProceed()
|
qtobject.authProceed()
|
||||||
dialog.close()
|
dialog.close()
|
||||||
})
|
})
|
||||||
@@ -527,21 +536,22 @@ ApplicationWindow
|
|||||||
}
|
}
|
||||||
|
|
||||||
property var _lastActive: 0 // record time of last activity
|
property var _lastActive: 0 // record time of last activity
|
||||||
property int _maxInactive: 30 // seconds
|
|
||||||
property bool _lockDialogShown: false
|
property bool _lockDialogShown: false
|
||||||
|
|
||||||
onActiveChanged: {
|
onActiveChanged: {
|
||||||
console.log('app active = ' + active)
|
console.log('app active = ' + active)
|
||||||
if (!active) {
|
if (active) {
|
||||||
// deactivated
|
if (!_lastActive) {
|
||||||
_lastActive = Date.now()
|
_lastActive = Date.now()
|
||||||
} else {
|
return
|
||||||
|
}
|
||||||
// activated
|
// activated
|
||||||
if (_lastActive != 0 && Date.now() - _lastActive > _maxInactive * 1000) {
|
if (Date.now() - _lastCorrectPinTime > _pinValidSeconds * 1000) {
|
||||||
if (_lockDialogShown || Config.pinCode == '')
|
if (_lockDialogShown || Config.pinCode == '')
|
||||||
return
|
return
|
||||||
var dialog = app.pinDialog.createObject(app, {mode: 'check', canCancel: false, pincode: Config.pinCode})
|
var dialog = app.pinDialog.createObject(app, {mode: 'check', canCancel: false, pincode: Config.pinCode})
|
||||||
dialog.accepted.connect(function() {
|
dialog.accepted.connect(function() {
|
||||||
|
_lastCorrectPinTime = Date.now()
|
||||||
dialog.close()
|
dialog.close()
|
||||||
_lockDialogShown = false
|
_lockDialogShown = false
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user