Commit 0787904e authored by Devin Lin's avatar Devin Lin 🎨
Browse files

lockscreen: Add support for passwordless logins

parent 8438027d
Pipeline #192633 passed with stage
in 1 minute and 10 seconds
/*
* SPDX-FileCopyrightText: 2021 Devin Lin <devin@kde.org>
*
* SPDX-License-Identifier: LGPL-2.0-or-later
*/
// SPDX-FileCopyrightText: 2021-2022 Devin Lin <devin@kde.org>
// SPDX-License-Identifier: LGPL-2.0-or-later
import QtQuick 2.15
import QtQuick.Layouts 1.15
......@@ -16,6 +13,8 @@ Flickable {
required property real keypadHeight
signal opened()
function cancelAnimations() {
positionAnim.stop();
}
......@@ -45,6 +44,12 @@ Flickable {
id: positionAnim
duration: PlasmaCore.Units.longDuration * 2
easing.type: Easing.OutCubic
onFinished: {
if (root.position === keypadHeight) {
root.opened();
}
}
}
// we use flickable solely for capturing flicks, not positioning elements
......@@ -55,7 +60,6 @@ Flickable {
readonly property real startContentY: contentHeight / 2
property int oldPosition: position
property bool movingUp: false
......
......@@ -69,6 +69,13 @@ PlasmaCore.ColorScope {
property real openFactor: position / keypadHeight
onOpened: {
if (root.lockScreenState.passwordless) {
// try unlocking if flicked to the top, and we have passwordless login
root.lockScreenState.tryPassword();
}
}
keypadHeight: PlasmaCore.Units.gridUnit * 20
// go to closed position when loaded
......@@ -162,6 +169,7 @@ PlasmaCore.ColorScope {
Loader {
width: parent.width
asynchronous: true
active: !root.lockScreenState.passwordless // only load keypad if not passwordless
anchors.bottom: parent.bottom
......
/*
* SPDX-FileCopyrightText: 2022 Devin Lin <espidev@gmail.com>
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
// SPDX-FileCopyrightText: 2022 Devin Lin <espidev@gmail.com>
// SPDX-License-Identifier: GPL-2.0-or-later
import QtQml 2.15
import QtQuick 2.15
......@@ -16,8 +13,12 @@ QtObject {
// whether waiting for authentication after trying password
property bool waitingForAuth: false
// the info message given
property string info: ""
// whether the lockscreen was passwordless
property bool passwordless: true
signal reset()
signal unlockSucceeded()
signal unlockFailed()
......@@ -26,6 +27,7 @@ QtObject {
if (root.password !== '') { // prevent typing lock when password is empty
waitingForAuth = true;
}
connections.hasPrompt = true;
authenticator.tryUnlock();
}
......@@ -34,21 +36,35 @@ QtObject {
root.reset();
}
Component.onCompleted: {
// determine whether we have passwordless login
// if we do, authenticator will emit a success signal, otherwise it will emit failure
authenticator.tryUnlock();
}
property var connections: Connections {
target: authenticator
// false for our test of whether we have passwordless login, otherwise it's true
property bool hasPrompt: false
function onSucceeded() {
console.log('login succeeded');
root.waitingForAuth = false;
root.unlockSucceeded();
Qt.quit();
if (hasPrompt) {
console.log('login succeeded');
root.waitingForAuth = false;
root.unlockSucceeded();
Qt.quit();
}
}
function onFailed() {
console.log('login failed');
root.waitingForAuth = false;
root.password = "";
root.unlockFailed();
root.passwordless = false;
if (hasPrompt) {
console.log('login failed');
root.waitingForAuth = false;
root.password = "";
root.unlockFailed();
}
}
function onInfoMessage(msg) {
......
Supports Markdown
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