feat: support configuring remaining TOTP token details

With this change both epoch and hash algoritm may now be configured for TOTP tokens.

Issues: #7
master
Johan Ouwerkerk 2020-07-24 20:56:16 +02:00
parent e539f2cf22
commit fa4f6f651e
1 changed files with 53 additions and 1 deletions

View File

@ -15,7 +15,9 @@ Kirigami.FormLayout {
property Models.ValidatedAccountInput validatedInput
property bool timeStepAcceptable: timeStepField.acceptableInput
property bool acceptable: timeStepAcceptable
property bool algorithmAcceptable: sha1Radio.checked || sha256Radio.checked || sha512Radio.checked
property bool epochAcceptable: epochField.acceptableInput
property bool acceptable: timeStepAcceptable && algorithmAcceptable && epochAcceptable
Controls.TextField {
id: timeStepField
@ -31,6 +33,20 @@ Kirigami.FormLayout {
}
}
}
Controls.TextField {
id: epochField
Kirigami.FormData.label: i18nc("@label:textbox", "Starting at:")
text: validatedInput ? validatedInput.epoch : ""
validator: Validators.TOTPEpochValidator {
}
onTextChanged: {
if (acceptableInput) {
validatedInput.epoch = text;
}
}
}
/*
* OATH tokens are derived from a 32bit value, base-10 encoded.
* Meaning tokens should not be longer than 10 digits max.
@ -48,4 +64,40 @@ Kirigami.FormLayout {
validatedInput.tokenLength = value;
}
}
ColumnLayout {
Layout.rowSpan: 3
Kirigami.FormData.label: i18nc("@label:chooser", "Hash algorithm:")
Kirigami.FormData.buddyFor: sha1Radio
Controls.RadioButton {
id: sha1Radio
checked: validatedInput.algorithm === Models.ValidatedAccountInput.Sha1
text: i18nc("@option:radio", "SHA-1")
onCheckedChanged: {
if (checked) {
validatedInput.algorithm = Models.ValidatedAccountInput.Sha1;
}
}
}
Controls.RadioButton {
id: sha256Radio
checked: validatedInput.algorithm === Models.ValidatedAccountInput.Sha256
text: i18nc("@option:radio", "SHA-256")
onCheckedChanged: {
if (checked) {
validatedInput.algorithm = Models.ValidatedAccountInput.Sha256;
}
}
}
Controls.RadioButton {
id: sha512Radio
checked: validatedInput.algorithm === Models.ValidatedAccountInput.Sha512
text: i18nc("@option:radio", "SHA-512")
onCheckedChanged: {
if (checked) {
validatedInput.algorithm = Models.ValidatedAccountInput.Sha512;
}
}
}
}
}