Skip to content

Commit

Permalink
Added show password toggle button
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancescoLanthaler committed Nov 18, 2024
1 parent a077acb commit 897193c
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 7 deletions.
13 changes: 9 additions & 4 deletions src/controllers/session/login/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,16 @@
<h1 class="sectionTitle">${HeaderPleaseSignIn}</h1>
</div>
<div class="inputContainer">
<input is="emby-input" type="text" id="txtManualName" required="required" label="${LabelUser}" autocomplete="username" autocapitalize="off" />
<input is="emby-input" type="text" id="txtManualName" required="required" label="${LabelUser}"
autocomplete="username" autocapitalize="off" />
</div>

<div class="inputContainer">
<input is="emby-input" id="txtManualPassword" type="password" label="${LabelPassword}" autocomplete="current-password" />
<div class="inputContainer passwordInput">
<label for="txtManualPassword">${LabelPassword}</label>
<div class="inputInner">
<input is="emby-input" id="txtManualPassword" type="password" autocomplete="current-password" />
<span class="togglePasswordVisibility material-icons">visibility</span>
</div>
</div>

<label class="checkboxContainer">
Expand Down Expand Up @@ -55,4 +60,4 @@ <h1 style="margin-top:1em;">${HeaderPleaseSignIn}</h1>
</div>
</div>
</div>
</div>
</div>
24 changes: 21 additions & 3 deletions src/controllers/session/login/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ function authenticateQuickConnect(apiClient, targetUrl) {

const connectUrl = apiClient.getUrl('/QuickConnect/Connect?Secret=' + json.Secret);

const interval = setInterval(function() {
apiClient.getJSON(connectUrl).then(async function(data) {
const interval = setInterval(function () {
apiClient.getJSON(connectUrl).then(async function (data) {
if (!data.Authenticated) {
return;
}
Expand Down Expand Up @@ -97,7 +97,7 @@ function authenticateQuickConnect(apiClient, targetUrl) {
}, 5000, connectUrl);

return true;
}, function(e) {
}, function (e) {
Dashboard.alert({
message: globalize.translate('QuickConnectNotActive'),
title: globalize.translate('HeaderError')
Expand Down Expand Up @@ -132,6 +132,14 @@ function showManualForm(context, showCancel, focusPassword) {
}
}

function togglePasswordVisibility(context) {
const passwordInput = context.querySelector('#txtManualPassword');
const icon = context.querySelector('.togglePasswordVisibility');

icon.innerHTML = passwordInput.type === 'password' ? 'visibility_off' : 'visibility';
passwordInput.type = passwordInput.type === 'password' ? 'text' : 'password';
}

function loadUserList(context, apiClient, users) {
let html = '';

Expand Down Expand Up @@ -238,10 +246,20 @@ export default function (view, params) {
});
view.querySelector('.manualLoginForm').addEventListener('submit', function (e) {
appSettings.enableAutoLogin(view.querySelector('.chkRememberLogin').checked);
const passwordInput = view.querySelector('#txtManualPassword');
const icon = view.querySelector('.togglePasswordVisibility');

icon.innerHTML = 'visibility';
passwordInput.type = 'password'; // Reset password visibility
authenticateUserByName(view, getApiClient(), getTargetUrl(), view.querySelector('#txtManualName').value, view.querySelector('#txtManualPassword').value);
e.preventDefault();
return false;
});

view.querySelector('.togglePasswordVisibility').addEventListener('click', function () {
togglePasswordVisibility(view);
});

view.querySelector('.btnForgotPassword').addEventListener('click', function () {
Dashboard.navigate('forgotpassword.html');
});
Expand Down
21 changes: 21 additions & 0 deletions src/controllers/session/login/login.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,27 @@
margin-top: 2em;
}

.inputInner {
position: relative;
height: fit-content;

label {
display: none;
}

.togglePasswordVisibility {
position: absolute;
right: 0.5rem;
top: 50%;
transform: translateY(-50%);
bottom: 0;
display: flex;
height: fit-content;
align-items: center;
cursor: pointer;
}
}

.loginDisclaimer {
margin: 0 auto;

Expand Down

0 comments on commit 897193c

Please sign in to comment.