Add cooldown period for HOTP creds

This commit is contained in:
Dag Heyman 2017-02-17 10:14:37 +01:00
parent 084191e467
commit f11d3874bb
No known key found for this signature in database
GPG Key ID: 06FC004369E7D338

View File

@ -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
}