summaryrefslogtreecommitdiff
path: root/auth/examples/full_example.js
blob: 7359784b1f4056be059e587e10ef723382545823 (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
#!/usr/bin/env -S gjs -m

import Auth from "gi://AstalAuth";
import GLib from "gi://GLib";

const loop = GLib.MainLoop.new(null, false);

const pam = new Auth.Pam();
pam.connect("auth-prompt-visible", (p, msg) => {
    print(msg);
    p.supply_secret("");
});
pam.connect("auth-prompt-hidden", (p, msg) => {
    print(msg);
    p.supply_secret("password");
});
pam.connect("auth-info", (p, msg) => {
    print(msg);
    p.supply_secret("");
});
pam.connect("auth-error", (p, msg) => {
    print(msg);
    p.supply_secret("");
});

pam.connect("success", p => {
    print("authentication sucessful");
    loop.quit();
});
pam.connect("fail", (p, msg) => {
    print(msg);
    loop.quit();
});

pam.start_authenticate();

loop.runAsync()