diff --git a/index.html b/index.html index 181158d..b7df774 100644 --- a/index.html +++ b/index.html @@ -58,7 +58,7 @@
- +
@@ -75,6 +75,7 @@ + diff --git a/js/authenticate.js b/js/authenticate.js new file mode 100644 index 0000000..bc2adfb --- /dev/null +++ b/js/authenticate.js @@ -0,0 +1,25 @@ +function authenticate(){ + const selectedUser = users[currentUser].id; + + lightdm.cancel_authentication(); + lightdm.authenticate(selectedUser); +} + +async function authenticationComplete() { + const selectedSession = sessions[currentSession].id; + + await lightdm.respond($("#password-input").value); + lightdm.start_session(selectedSession); +} + +function bindAuthenticate() { + $("#password-input").onkeypress = function(e) { + var keycode = e.code || e.key; + if(keycode == "Enter"){ + authenticate(); + return; + } + } + + window.lightdm.authentication_complete.connect(authenticationComplete); +} diff --git a/js/class/util.js b/js/class/util.js index 4e7e1cb..4accb1b 100644 --- a/js/class/util.js +++ b/js/class/util.js @@ -1 +1,5 @@ -function $(c) { return document.querySelector(c); } \ No newline at end of file +function $(c) { return document.querySelector(c); } + +function wait(ms) { + return new Promise((resolve) => setTimeout(resolve, ms)); +} diff --git a/js/index.js b/js/index.js index 550fdad..5e2c77b 100644 --- a/js/index.js +++ b/js/index.js @@ -7,7 +7,7 @@ async function initGreeter(){ populateSessions(); populateUsers(); - console.log(lightdm.default_session); + bindAuthenticate(); } window.addEventListener("GreeterReady", () => {