2019-09-09 15:12:58 +03:00
|
|
|
import QtQuick 2.9
|
|
|
|
import QtQuick.Controls 2.2
|
|
|
|
import QtQuick.Layouts 1.3
|
|
|
|
import QtQuick.Controls.Material 2.2
|
|
|
|
import QtGraphicalEffects 1.0
|
|
|
|
|
2019-10-29 11:52:47 +03:00
|
|
|
Flickable {
|
2019-09-09 15:12:58 +03:00
|
|
|
|
2020-01-14 17:13:35 +03:00
|
|
|
readonly property int dynamicWidth: 648
|
2019-09-09 15:12:58 +03:00
|
|
|
readonly property int dynamicMargin: 32
|
|
|
|
|
|
|
|
id: enterPasswordViewId
|
|
|
|
objectName: 'enterPasswordView'
|
2019-09-09 17:59:30 +03:00
|
|
|
property string title: qsTr("Unlock YubiKey")
|
2019-09-09 15:12:58 +03:00
|
|
|
|
2019-10-29 11:52:47 +03:00
|
|
|
ScrollBar.vertical: ScrollBar {
|
|
|
|
width: 8
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
hoverEnabled: true
|
|
|
|
z: 2
|
|
|
|
}
|
|
|
|
boundsBehavior: Flickable.StopAtBounds
|
2019-09-09 15:12:58 +03:00
|
|
|
|
|
|
|
contentWidth: app.width
|
|
|
|
|
|
|
|
function clear() {
|
|
|
|
passwordField.text = ""
|
|
|
|
rememberPasswordCheckBox.checked = false
|
|
|
|
}
|
|
|
|
|
|
|
|
function validate() {
|
|
|
|
if (passwordField.text.valueOf().length > 0) {
|
|
|
|
yubiKey.validate(passwordField.text,
|
|
|
|
rememberPasswordCheckBox.checked, function (resp) {
|
|
|
|
if (resp.success) {
|
|
|
|
yubiKey.currentDeviceValidated = true
|
|
|
|
yubiKey.calculateAll(navigator.goToCredentials)
|
|
|
|
} else {
|
|
|
|
clear()
|
|
|
|
navigator.snackBarError(
|
|
|
|
navigator.getErrorMessage(
|
|
|
|
resp.error_id))
|
|
|
|
console.log("validate failed:",
|
|
|
|
resp.error_id)
|
|
|
|
passwordField.textField.forceActiveFocus()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
passwordField.textField.forceActiveFocus()
|
|
|
|
}
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
anchors.fill: parent
|
2019-11-27 16:44:27 +03:00
|
|
|
anchors.topMargin: 16
|
2019-09-09 15:12:58 +03:00
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
|
|
|
Pane {
|
|
|
|
Layout.alignment: Qt.AlignCenter | Qt.AlignTop
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.maximumWidth: dynamicWidth + dynamicMargin
|
|
|
|
Layout.topMargin: 0
|
2019-11-27 16:44:27 +03:00
|
|
|
Material.elevation: 1
|
|
|
|
Material.background: defaultElevated
|
2019-09-09 15:12:58 +03:00
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
width: app.width - dynamicMargin
|
|
|
|
< dynamicWidth ? app.width - dynamicMargin : dynamicWidth
|
|
|
|
spacing: 8
|
|
|
|
|
|
|
|
Label {
|
|
|
|
Layout.topMargin: 16
|
2019-09-09 17:59:30 +03:00
|
|
|
text: qsTr("To prevent unauthorized access this YubiKey is protected with a password.")
|
2019-09-09 15:12:58 +03:00
|
|
|
Layout.maximumWidth: app.width - dynamicMargin
|
|
|
|
< dynamicWidth ? app.width - dynamicMargin : dynamicWidth
|
|
|
|
Layout.rowSpan: 1
|
|
|
|
lineHeight: 1.2
|
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
font.pixelSize: 13
|
|
|
|
Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter
|
2019-11-27 16:44:27 +03:00
|
|
|
color: primaryColor
|
|
|
|
opacity: highEmphasis
|
2019-09-09 15:12:58 +03:00
|
|
|
Layout.fillWidth: true
|
|
|
|
bottomPadding: 8
|
|
|
|
Layout.leftMargin: 8
|
|
|
|
Layout.rightMargin: 8
|
|
|
|
}
|
|
|
|
|
|
|
|
StyledTextField {
|
|
|
|
id: passwordField
|
|
|
|
labelText: qsTr("Password")
|
|
|
|
echoMode: TextInput.Password
|
|
|
|
Keys.onEnterPressed: validate()
|
|
|
|
Keys.onReturnPressed: validate()
|
|
|
|
Layout.fillWidth: true
|
|
|
|
KeyNavigation.backtab: unlockBtn
|
|
|
|
KeyNavigation.tab: rememberPasswordCheckBox
|
|
|
|
onSubmit: validate()
|
|
|
|
Layout.leftMargin: 8
|
|
|
|
Layout.rightMargin: 8
|
|
|
|
}
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
CheckBox {
|
|
|
|
Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter
|
|
|
|
id: rememberPasswordCheckBox
|
2019-10-02 15:40:08 +03:00
|
|
|
font.pixelSize: 13
|
2019-09-09 17:59:30 +03:00
|
|
|
text: qsTr("Remember password")
|
2019-09-09 15:12:58 +03:00
|
|
|
leftPadding: 0
|
|
|
|
KeyNavigation.backtab: passwordField.textField
|
|
|
|
KeyNavigation.tab: unlockBtn
|
|
|
|
indicator.width: 16
|
|
|
|
indicator.height: 16
|
|
|
|
Layout.leftMargin: 8
|
|
|
|
Layout.topMargin: -8
|
|
|
|
}
|
|
|
|
Item {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
StyledButton {
|
|
|
|
id: unlockBtn
|
2019-09-09 17:59:30 +03:00
|
|
|
text: qsTr("Unlock")
|
|
|
|
toolTipText: qsTr("Unlock YubiKey")
|
2019-09-09 15:12:58 +03:00
|
|
|
enabled: passwordField.text.valueOf().length > 0
|
|
|
|
Layout.alignment: Qt.AlignRight | Qt.AlignVCenter
|
|
|
|
onClicked: validate()
|
|
|
|
KeyNavigation.backtab: rememberPasswordCheckBox
|
|
|
|
KeyNavigation.tab: passwordField.textField
|
|
|
|
Layout.rightMargin: 8
|
|
|
|
Layout.bottomMargin: 8
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|