Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add show password toggle button #6325

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading