repositories / dotfiles
dotfiles
bugabingas dorkfiles
owned by admin
quickshell/nuguland/test-fixtures/ui/fixture-services/lifecycle/Privilege.qml
Rawimport QtQuick
Item {
property bool active: false
property bool confirming: false
property string error: ""
// A submission waits for settle(), like a slow PAM check.
property bool awaitingCompletion: false
property int submissions: 0
property int cancellations: 0
property int denials: 0
property bool receivedLiteral: false
readonly property var request: ({
"message": "fixture authorization only",
"prompt": "fixture input",
"responseVisible": false
})
function begin() {
// Match production request ordering: keep the surface mapped when
// replacing success confirmation with the next authorization request.
active = true;
confirming = false;
awaitingCompletion = false;
error = "";
}
function submit(secret) {
submissions++;
receivedLiteral = secret === "fixture-only";
awaitingCompletion = true;
}
// Answers the waiting submission: the first is rejected, a later literal one authorized.
function settle() {
if (!awaitingCompletion)
return;
awaitingCompletion = false;
if (submissions === 1 || !receivedLiteral) {
error = "Authentication failed";
} else {
confirming = true;
active = false;
error = "";
}
}
function cancel() {
cancellations++;
active = false;
confirming = false;
awaitingCompletion = false;
error = "";
}
function deny() {
denials++;
active = false;
}
}