Basic authentication flow

This commit is contained in:
Jakub Nowak 2025-02-09 20:43:04 +08:00
parent c58cf0e10c
commit 2e38ecd15b
4 changed files with 33 additions and 3 deletions

View file

@ -58,7 +58,7 @@
</div> </div>
<div class="input-container"> <div class="input-container">
<input placeholder="" type="password" tabindex="1" /> <input id="password-input" placeholder="" type="password" tabindex="1" />
</div> </div>
</div> </div>
@ -75,6 +75,7 @@
<script src="js/session-select.js"></script> <script src="js/session-select.js"></script>
<script src="js/idle-hide.js"></script> <script src="js/idle-hide.js"></script>
<script src="js/hostname.js"></script> <script src="js/hostname.js"></script>
<script src="js/authenticate.js"></script>
<script src="js/index.js"></script> <script src="js/index.js"></script>
</body> </body>
</html> </html>

25
js/authenticate.js Normal file
View file

@ -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);
}

View file

@ -1 +1,5 @@
function $(c) { return document.querySelector(c); } function $(c) { return document.querySelector(c); }
function wait(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}

View file

@ -7,7 +7,7 @@ async function initGreeter(){
populateSessions(); populateSessions();
populateUsers(); populateUsers();
console.log(lightdm.default_session); bindAuthenticate();
} }
window.addEventListener("GreeterReady", () => { window.addEventListener("GreeterReady", () => {