Skip to content

Commit 6252331

Browse files
authored
V2.0.4 (#29)
* authenticate * greeter-screen: add space key to close greeter * use parseInt
1 parent b68d26c commit 6252331

File tree

5 files changed

+29
-26
lines changed

5 files changed

+29
-26
lines changed

js/accounts.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ class Accounts {
6969
}
7070

7171
_setAccountDefaultOnStartUpFallback() {
72-
this._defaultUser = this._usersObject[0].username;
73-
this._defaultUserDisplayName = this._usersObject[0].display_name;
74-
this._defaultUserProfileImage = this._usersObject[0].image;
72+
this._defaultUser = this._usersObject[parseInt(0, 10)].username;
73+
this._defaultUserDisplayName = this._usersObject[parseInt(0, 10)].display_name;
74+
this._defaultUserProfileImage = this._usersObject[parseInt(0, 10)].image;
7575
this._defaultUserProfileImageFallback = 'assets/profiles/user.svg';
7676
const userDefault = {
7777
'userName': this._defaultUser,

js/authenticate.js

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class Authenticate {
4141
return errorMessages[Math.floor(Math.random() * errorMessages.length)];
4242
}
4343

44+
// Start authentication
4445
startAuthentication() {
4546
lightdm.cancel_authentication();
4647
lightdm.authenticate(String(accounts.getDefaultUserName()));
@@ -66,6 +67,12 @@ class Authenticate {
6667

6768
// You passed to authentication
6869
_authenticationSuccess() {
70+
this._password = null;
71+
72+
// Make password input read-only
73+
this._passwordInput.readOnly = true;
74+
this._passwordInput.blur();
75+
6976
// Success messages
7077
this._passwordBox.classList.add('authentication-success');
7178
this._tooltipPassword.innerText = this._returnRandomSuccessfulMessages();
@@ -84,22 +91,14 @@ class Authenticate {
8491

8592
// Remove authentication failure messages
8693
_authFailedRemove() {
87-
// Remove warnings and tooltip
88-
if ((!this._passwordBox.classList.contains('authentication-failed')) &&
89-
(!this._tooltipPassword.classList.contains('tooltip-error'))) {
90-
return;
91-
}
92-
setTimeout(
93-
() => {
94-
this._tooltipPassword.classList.remove('tooltip-error');
95-
this._passwordBox.classList.remove('authentication-failed');
96-
},
97-
250
98-
);
94+
this._tooltipPassword.classList.remove('tooltip-error');
95+
this._passwordBox.classList.remove('authentication-failed');
9996
}
10097

10198
// You failed to authenticate
10299
_authenticationFailed() {
100+
this._password = null;
101+
103102
// New authentication session
104103
this.startAuthentication();
105104
this._passwordInput.value = '';
@@ -125,13 +124,9 @@ class Authenticate {
125124
this._buttonAuthenticate.addEventListener(
126125
'click',
127126
() => {
128-
// Save input value to variable
127+
console.log(lightdm.in_authentication);
128+
this._authFailedRemove();
129129
this._password = this._passwordInput.value;
130-
if (this._password.length < 1) {
131-
return;
132-
}
133-
134-
// Validation
135130
lightdm.respond(String(this._password));
136131
}
137132
);
@@ -145,9 +140,6 @@ class Authenticate {
145140
this._authFailedRemove();
146141
this._password = this._passwordInput.value;
147142
if (e.key === 'Enter') {
148-
if (this._password.length < 1) {
149-
return;
150-
}
151143
lightdm.respond(String(this._password));
152144
}
153145
}

js/greeter.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ class GreeterScreen {
99
this._arrowIndicatorClickEvent();
1010
}
1111

12+
getGreeterVisibility() {
13+
return this._screenGreeterVisible;
14+
}
15+
1216
_buttonGreeterClickEvent() {
1317
this._buttonScreenGreeter.addEventListener(
1418
'click',

js/key-events.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,13 @@ class KeyEvents {
6666
return;
6767
}
6868

69+
if ((e.key === ' ') || (e.code === 'Space')) {
70+
if (greeterScreen.getGreeterVisibility()) {
71+
greeterScreen.toggleGreeter();
72+
return;
73+
}
74+
}
75+
6976
if (e.key === this._closeKey) {
7077
e.preventDefault();
7178

js/sessions.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ class Sessions {
3131
}
3232

3333
_setSessionListDefaultOnStartUpFallback() {
34-
this._defaultSession = this._sessionsObject[0].key;
34+
this._defaultSession = this._sessionsObject[parseInt(0, 10)].key;
3535
this._localStorage.setItem('defaultSession', this._defaultSession);
3636
}
3737

3838
_setSessionListDefaultOnStartUp() {
3939
this._defaultSession = this._localStorage.getItem('defaultSession') ||
40-
this._sessionsObject[0].key || lightdm.default_session;
40+
this._sessionsObject[parseInt(0, 10)].key || lightdm.default_session;
4141
let defaultSessionItem = document.querySelector(`#button-sessions-item-${this._defaultSession}`);
4242
if (!defaultSessionItem) {
4343
// If the should've been default session does not exist

0 commit comments

Comments
 (0)