From 1ae4a0f26b1d2b6c97d92ddf172ce7896ee84440 Mon Sep 17 00:00:00 2001 From: wambui-pixel <80099068+wambui-pixel@users.noreply.github.com> Date: Tue, 19 Mar 2024 18:01:38 +0300 Subject: [PATCH] MG-177 - Add password visibility toggle to login page (#248) * Add password visibility eye toggle functionality Signed-off-by: wambuipixel * Add password visibility eye toggle functionality on registration, update password and reset password pages Signed-off-by: wambuipixel * Code Formatting Signed-off-by: wambuipixel * Ports and file name correction Signed-off-by: wambuipixel * fix lint error Signed-off-by: wambuipixel * margin fix Signed-off-by: wambuipixel * comment fix Signed-off-by: wambuipixel --------- Signed-off-by: wambuipixel --- ui/web/templates/login.html | 27 +++++++++++++++++++++----- ui/web/templates/registration.html | 24 ++++++++++++++++++----- ui/web/templates/resetpassword.html | 29 ++++++++++++++++++++++++---- ui/web/templates/updatepassword.html | 27 +++++++++++++++++++++----- 4 files changed, 88 insertions(+), 19 deletions(-) diff --git a/ui/web/templates/login.html b/ui/web/templates/login.html index eb2aa669..bb260fcd 100644 --- a/ui/web/templates/login.html +++ b/ui/web/templates/login.html @@ -30,9 +30,9 @@

Login

- + +
@@ -153,7 +154,8 @@ }); diff --git a/ui/web/templates/updatepassword.html b/ui/web/templates/updatepassword.html index 27420c45..04a1bb60 100644 --- a/ui/web/templates/updatepassword.html +++ b/ui/web/templates/updatepassword.html @@ -25,29 +25,31 @@

Update Password

- + +
- + +
@@ -100,7 +102,22 @@

Update Password

return false; }); } - + // Code for toggling the visibility of the password + const togglePassword = document.querySelectorAll(".password-toggle-icon i"); + togglePassword.forEach((icon) => { + icon.addEventListener("click", function () { + const passwordField = icon.parentElement.previousElementSibling; + if (passwordField.type === "password") { + passwordField.type = "text"; + icon.classList.remove("fa-eye"); + icon.classList.add("fa-eye-slash"); + } else { + passwordField.type = "password"; + icon.classList.remove("fa-eye-slash"); + icon.classList.add("fa-eye"); + } + }); + }); function showError(errorMessage) { var loginError = document.getElementById("oldpassError"); loginError.innerHTML = errorMessage;