Skip to content

Commit 9d6dd5f

Browse files
committed
Squashed commit of the following:
commit 95d7e3b Author: Freek Bes <[email protected]> Date: Mon Aug 11 16:27:05 2025 +0200 update comment commit d2d2429 Author: Freek Bes <[email protected]> Date: Mon Aug 11 16:11:43 2025 +0200 allow blocking on authenticationComplete event can be useful for animations or for blocking actions
1 parent c23350a commit 9d6dd5f

File tree

4 files changed

+27
-14
lines changed

4 files changed

+27
-14
lines changed

client/auth.ts

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,14 @@ export interface AuthenticatorEvents {
88

99
/**
1010
* This event gets called when the login process completes without error.
11+
* The event handler must return a Promise that resolves to a boolean value.
12+
* When this value is true, the user session will be started.
13+
* Otherwise, the user will be returned to the greeter.
14+
* This allows for custom handling of the authentication result or adding another form on top.
15+
* The AuthenticationFailure event is not called afterwards, so update the UI accordingly if
16+
* false is returned.
1117
*/
12-
authenticationComplete: () => void;
18+
authenticationComplete: () => Promise<boolean>;
1319

1420
/**
1521
* This event gets called when the login process fails due to an authentication failure (wrong username or password).
@@ -103,27 +109,31 @@ export class Authenticator {
103109
});
104110

105111
// This event gets called when LightDM says the authentication was successful and a session should be started
106-
lightdm.authentication_complete.connect(() => {
112+
lightdm.authentication_complete.connect(async () => {
107113
try {
108-
this._authenticating = false;
109114
console.log("LightDM authentication complete. Checking results...");
110-
if (lightdm.is_authenticated) {
111-
this._authenticated = true;
112-
console.log("LightDM authentication successful! Starting session...");
115+
if (!lightdm.is_authenticated) {
116+
this._authenticating = false;
117+
console.log("LightDM authentication failed. User not found or password incorrect.");
118+
this._stopAuthentication();
113119
if (this._authEvents) {
114-
this._authEvents.authenticationComplete();
120+
this._authEvents.authenticationFailure();
115121
}
122+
return;
123+
}
124+
this._authenticated = true;
125+
this._authenticating = false;
126+
console.log("LightDM authentication successful! Starting session...");
127+
const eventResult = (this._authEvents) ? await this._authEvents.authenticationComplete() : Promise.resolve(true);
128+
if (eventResult) {
116129
lightdm.start_session(this._session ?? null);
117130
}
118131
else {
119-
console.log("LightDM authentication failed. User not found or password incorrect.");
120132
this._stopAuthentication();
121-
if (this._authEvents) {
122-
this._authEvents.authenticationFailure();
123-
}
124133
}
125134
}
126135
catch (err) {
136+
this._authenticating = false;
127137
window.ui.setDebugInfo(String(err));
128138
if (this._authEvents) {
129139
this._authEvents.errorMessage(String(err));

client/uis/screens/examscreen.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ export class ExamModeUI extends UIScreen {
1717
authenticationStart: () => {
1818
this._disableForm();
1919
},
20-
authenticationComplete: () => {
20+
authenticationComplete: async () => {
2121
// TODO: add loading animation here
22+
return true;
2223
},
2324
authenticationFailure: () => {
2425
this._enableForm();

client/uis/screens/lockscreen.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ export class LockScreenUI extends UIScreen {
1414
authenticationStart: () => {
1515
this._disableForm();
1616
},
17-
authenticationComplete: () => {
17+
authenticationComplete: async () => {
1818
// TODO: Add a loading animation here
19+
return true;
1920
},
2021
authenticationFailure: () => {
2122
this._enableForm();

client/uis/screens/loginscreen.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ export class LoginScreenUI extends UIScreen {
77
authenticationStart: () => {
88
this._disableForm();
99
},
10-
authenticationComplete: () => {
10+
authenticationComplete: async () => {
1111
// TODO: Add a loading animation here
12+
return true;
1213
},
1314
authenticationFailure: () => {
1415
this._enableForm();

0 commit comments

Comments
 (0)