summaryrefslogtreecommitdiff
path: root/examples/full_example.js
diff options
context:
space:
mode:
authorkotontrion <[email protected]>2024-05-19 19:15:09 +0200
committerkotontrion <[email protected]>2024-05-19 19:15:09 +0200
commit2308e485ec479dd120baf4496b839612eb96aaa0 (patch)
treebeb0e26820c512e702509427d90132c41ca5b45c /examples/full_example.js
parentdf48cbd0695f1145fde13da10dbe596f8a09822e (diff)
add: Readme and gjs examples
Diffstat (limited to 'examples/full_example.js')
-rw-r--r--examples/full_example.js38
1 files changed, 38 insertions, 0 deletions
diff --git a/examples/full_example.js b/examples/full_example.js
new file mode 100644
index 0000000..7359784
--- /dev/null
+++ b/examples/full_example.js
@@ -0,0 +1,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()
+