Commit fdf52eda authored by Kevin Whitaker's avatar Kevin Whitaker

Add code to allow TOTP codes to be made and shown. Not sure if the code given...

Add code to allow TOTP codes to be made and shown. Not sure if the code given by pyotp is always fresh, will have to see if it gives any indication.
parent f6e68361
......@@ -75,6 +75,7 @@ class OTPModel(QtCore.QObject):
def setAlgo(self,algo):
self._algo = algo
@QtCore.Slot(result=str)
def getOTPCode(self):
if self._OTPType == "TOTP":
return pyotp.TOTP(self._secret).now()
......
......@@ -32,6 +32,19 @@ Item {
Layout.fillWidth: true
visible: true
}
Timer {
id: timeoutTimer
repeat: true
signal stopTOTP
onTriggered: {
if(timeout.value > 0) {
timeout.value = timeout.value - 1
} else {
timeoutTimer.stop()
stopTOTP()
}
}
}
}
}
ListView {
......@@ -52,6 +65,28 @@ Item {
width: 2
color: "grey"
}
MouseArea {
anchors.fill: parent
onClicked: {
if(display.OTPType == "TOTP") {
if(!timeoutTimer.running) {
timeout.to = display.timeout
timeout.value = display.timeout
otpCode.text = display.getOTPCode()
timeoutTimer.start()
timeoutTimer.stopTOTP.connect(removeCode)
} else {
timeoutTimer.stop()
timeout.value = 0
otpCode.text = ""
}
}
}
function removeCode() {
otpCode.text = ""
timeoutTimer.stopTOTP.disconnect(removeCode)
}
}
RowLayout {
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment