mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2025-01-06 02:37:21 +03:00
Add cooldown period for HOTP creds
This commit is contained in:
parent
084191e467
commit
f11d3874bb
23
qml/Main.qml
23
qml/Main.qml
@ -17,6 +17,7 @@ ApplicationWindow {
|
||||
property var credentials: device.credentials
|
||||
property bool validated: device.validated
|
||||
property bool hasDevice: device.hasDevice
|
||||
property var cooldowns: []
|
||||
|
||||
PasswordPrompt {
|
||||
id: passwordPrompt
|
||||
@ -34,7 +35,6 @@ ApplicationWindow {
|
||||
onCredentialsChanged: {
|
||||
updateExpiration()
|
||||
touchYourYubikey.close()
|
||||
console.log('CREDENTIALS ', JSON.stringify(credentials))
|
||||
}
|
||||
|
||||
SystemPalette {
|
||||
@ -167,9 +167,18 @@ ApplicationWindow {
|
||||
visible: repeater.selected != null
|
||||
&& (repeater.selected.oath_type === "hotp"
|
||||
|| repeater.selected.touch === true)
|
||||
enabled: repeater.selected != null && !isInCoolDown(repeater.selected.name)
|
||||
text: qsTr('Generate code')
|
||||
shortcut: "Space"
|
||||
onTriggered: calculateCredential(repeater.selected)
|
||||
onTriggered: {
|
||||
if (!isInCoolDown(repeater.selected.name)) {
|
||||
calculateCredential(repeater.selected)
|
||||
if (repeater.selected.oath_type === "hotp") {
|
||||
cooldowns.push(repeater.selected.name)
|
||||
coolDownTimer.restart()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
MenuItem {
|
||||
text: qsTr('Delete')
|
||||
@ -178,6 +187,12 @@ ApplicationWindow {
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: coolDownTimer
|
||||
interval: 5000
|
||||
onTriggered: cooldowns = []
|
||||
}
|
||||
|
||||
Item {
|
||||
id: arrowKeys
|
||||
focus: true
|
||||
@ -298,6 +313,7 @@ ApplicationWindow {
|
||||
font.pointSize: 13
|
||||
}
|
||||
Text {
|
||||
opacity: isInCoolDown(modelData.name) ? 0.6 : 1
|
||||
visible: modelData.code != null
|
||||
text: qsTr('') + modelData.code
|
||||
font.family: "Verdana"
|
||||
@ -416,6 +432,9 @@ ApplicationWindow {
|
||||
return result
|
||||
}
|
||||
|
||||
function isInCoolDown(name) {
|
||||
return cooldowns.indexOf(name) !== -1
|
||||
}
|
||||
function hasIssuer(name) {
|
||||
return name.indexOf(':') !== -1
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user