Skip to content

Commit

Permalink
V2.0.4 (#29)
Browse files Browse the repository at this point in the history
* authenticate

* greeter-screen: add space key to close greeter

* use parseInt
  • Loading branch information
eromatiya authored Sep 17, 2020
1 parent b68d26c commit 6252331
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 26 deletions.
6 changes: 3 additions & 3 deletions js/accounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ class Accounts {
}

_setAccountDefaultOnStartUpFallback() {
this._defaultUser = this._usersObject[0].username;
this._defaultUserDisplayName = this._usersObject[0].display_name;
this._defaultUserProfileImage = this._usersObject[0].image;
this._defaultUser = this._usersObject[parseInt(0, 10)].username;
this._defaultUserDisplayName = this._usersObject[parseInt(0, 10)].display_name;
this._defaultUserProfileImage = this._usersObject[parseInt(0, 10)].image;
this._defaultUserProfileImageFallback = 'assets/profiles/user.svg';
const userDefault = {
'userName': this._defaultUser,
Expand Down
34 changes: 13 additions & 21 deletions js/authenticate.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class Authenticate {
return errorMessages[Math.floor(Math.random() * errorMessages.length)];
}

// Start authentication
startAuthentication() {
lightdm.cancel_authentication();
lightdm.authenticate(String(accounts.getDefaultUserName()));
Expand All @@ -66,6 +67,12 @@ class Authenticate {

// You passed to authentication
_authenticationSuccess() {
this._password = null;

// Make password input read-only
this._passwordInput.readOnly = true;
this._passwordInput.blur();

// Success messages
this._passwordBox.classList.add('authentication-success');
this._tooltipPassword.innerText = this._returnRandomSuccessfulMessages();
Expand All @@ -84,22 +91,14 @@ class Authenticate {

// Remove authentication failure messages
_authFailedRemove() {
// Remove warnings and tooltip
if ((!this._passwordBox.classList.contains('authentication-failed')) &&
(!this._tooltipPassword.classList.contains('tooltip-error'))) {
return;
}
setTimeout(
() => {
this._tooltipPassword.classList.remove('tooltip-error');
this._passwordBox.classList.remove('authentication-failed');
},
250
);
this._tooltipPassword.classList.remove('tooltip-error');
this._passwordBox.classList.remove('authentication-failed');
}

// You failed to authenticate
_authenticationFailed() {
this._password = null;

// New authentication session
this.startAuthentication();
this._passwordInput.value = '';
Expand All @@ -125,13 +124,9 @@ class Authenticate {
this._buttonAuthenticate.addEventListener(
'click',
() => {
// Save input value to variable
console.log(lightdm.in_authentication);
this._authFailedRemove();
this._password = this._passwordInput.value;
if (this._password.length < 1) {
return;
}

// Validation
lightdm.respond(String(this._password));
}
);
Expand All @@ -145,9 +140,6 @@ class Authenticate {
this._authFailedRemove();
this._password = this._passwordInput.value;
if (e.key === 'Enter') {
if (this._password.length < 1) {
return;
}
lightdm.respond(String(this._password));
}
}
Expand Down
4 changes: 4 additions & 0 deletions js/greeter.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ class GreeterScreen {
this._arrowIndicatorClickEvent();
}

getGreeterVisibility() {
return this._screenGreeterVisible;
}

_buttonGreeterClickEvent() {
this._buttonScreenGreeter.addEventListener(
'click',
Expand Down
7 changes: 7 additions & 0 deletions js/key-events.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ class KeyEvents {
return;
}

if ((e.key === ' ') || (e.code === 'Space')) {
if (greeterScreen.getGreeterVisibility()) {
greeterScreen.toggleGreeter();
return;
}
}

if (e.key === this._closeKey) {
e.preventDefault();

Expand Down
4 changes: 2 additions & 2 deletions js/sessions.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ class Sessions {
}

_setSessionListDefaultOnStartUpFallback() {
this._defaultSession = this._sessionsObject[0].key;
this._defaultSession = this._sessionsObject[parseInt(0, 10)].key;
this._localStorage.setItem('defaultSession', this._defaultSession);
}

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

0 comments on commit 6252331

Please sign in to comment.