blob: 05fd1de27cdeffa514fe93e628ffbe75e50c755c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
import QtQuick
import Quickshell
import Quickshell.Services.Pam
Scope {
id: root
signal unlocked()
signal failed()
property string currentText: ""
property bool unlockInProgress: false
property string pamMessage: ""
property bool pamError: false
onCurrentTextChanged: {
pamError = false;
pamMessage = "";
}
function tryUnlock() {
if (currentText === "" || unlockInProgress) return;
unlockInProgress = true;
pam.start();
}
function reset() {
currentText = "";
pamError = false;
pamMessage = "";
unlockInProgress = false;
}
PamContext {
id: pam
configDirectory: "pam"
config: "password.conf"
onPamMessage: {
root.pamMessage = pam.message;
root.pamError = pam.messageIsError;
if (this.responseRequired) {
this.respond(root.currentText);
}
}
onCompleted: result => {
if (result == PamResult.Success) {
root.currentText = "";
root.unlocked();
} else {
root.currentText = "";
root.pamError = true;
root.failed();
}
root.unlockInProgress = false;
}
}
}
|