Skip to content

Commit 41fc03a

Browse files
Merge pull request #741: Add show/hide password toggle to auth page
2 parents bc9451b + f3f11ad commit 41fc03a

4 files changed

Lines changed: 55 additions & 3 deletions

File tree

‎.DS_Store‎

8 KB
Binary file not shown.

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,4 @@ instance/
3232
*.db
3333
# Virtual Environment
3434
venv/
35+
.venv/

‎frontend/js/app.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3410,7 +3410,7 @@ async function handleAuth(event) {
34103410
const mode = form.dataset.mode || 'login';
34113411

34123412
const email = document.getElementById("email").value;
3413-
const password = form.querySelector('input[type="password"]').value;
3413+
const password = document.getElementById("password").value;
34143414
const usernameInput = document.getElementById("username");
34153415

34163416
// Helper to reset button state on failure

‎frontend/pages/auth.html‎

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,26 @@
202202

203203
.input-group {
204204
margin: 0;
205+
position: relative;
206+
}
207+
208+
.password-toggle-icon {
209+
position: absolute;
210+
right: 1.05rem;
211+
top: 50%;
212+
transform: translateY(-50%);
213+
cursor: pointer;
214+
color: var(--text-muted);
215+
transition: color 0.2s ease;
216+
z-index: 10;
217+
}
218+
219+
.password-toggle-icon:hover {
220+
color: var(--text-main);
221+
}
222+
223+
.auth-input.password-input {
224+
padding-right: 2.75rem;
205225
}
206226

207227
.auth-input {
@@ -395,8 +415,10 @@ <h2 id="authTitle">Welcome Back</h2>
395415
</div>
396416

397417
<div class="input-group">
398-
<input type="password" id="password" class="auth-input" placeholder="Password" value="demo123"
399-
required autocomplete="current-password">
418+
<input type="password" id="password" class="auth-input password-input" placeholder="Password"
419+
value="demo123" required autocomplete="current-password">
420+
<i class="fa-solid fa-eye password-toggle-icon" id="togglePassword" title="Show Password"
421+
aria-label="Show password" role="button" tabindex="0"></i>
400422
</div>
401423

402424
<!--
@@ -530,6 +552,35 @@ <h3 style="color: var(--text-main) !important;">Ambient Sanctuary</h3>
530552
}
531553
});
532554
}
555+
556+
const togglePassword = document.getElementById('togglePassword');
557+
if (togglePassword && passwordInput) {
558+
const toggleVisibility = () => {
559+
const type = passwordInput.getAttribute('type') === 'password' ? 'text' : 'password';
560+
passwordInput.setAttribute('type', type);
561+
562+
if (type === 'password') {
563+
togglePassword.classList.remove('fa-eye-slash');
564+
togglePassword.classList.add('fa-eye');
565+
togglePassword.setAttribute('title', 'Show Password');
566+
togglePassword.setAttribute('aria-label', 'Show password');
567+
} else {
568+
togglePassword.classList.remove('fa-eye');
569+
togglePassword.classList.add('fa-eye-slash');
570+
togglePassword.setAttribute('title', 'Hide Password');
571+
togglePassword.setAttribute('aria-label', 'Hide password');
572+
}
573+
};
574+
575+
togglePassword.addEventListener('click', toggleVisibility);
576+
577+
togglePassword.addEventListener('keydown', (e) => {
578+
if (e.key === 'Enter' || e.key === ' ') {
579+
e.preventDefault();
580+
toggleVisibility();
581+
}
582+
});
583+
}
533584
</script>
534585
<script src="../js/pwa.js"></script>
535586
<script>

0 commit comments

Comments
 (0)