diff --git a/portal/static/portal/js/independentLogin.js b/portal/static/portal/js/independentLogin.js new file mode 100644 index 000000000..3f10bb6a3 --- /dev/null +++ b/portal/static/portal/js/independentLogin.js @@ -0,0 +1,16 @@ +$(document).ready(() => { + $('#independent_student_login_form').on('click', '#password-field-icon', () => { + let inputType; + let dataIcon = $('#password-field-icon').attr('data-icon'); + if (dataIcon === 'material-symbols:visibility') { + inputType = 'password'; + dataIcon = 'material-symbols:visibility-off'; + } else { + inputType = 'text'; + dataIcon = 'material-symbols:visibility'; + } + + $('#id_password').attr('type', inputType); + $('#password-field-icon').attr('data-icon', dataIcon); + }); +}); diff --git a/portal/static/portal/js/organisation_manage.js b/portal/static/portal/js/organisation_manage.js index 255eaa285..f6977d944 100644 --- a/portal/static/portal/js/organisation_manage.js +++ b/portal/static/portal/js/organisation_manage.js @@ -89,3 +89,65 @@ function showDeleteAccountConfirmation(delete_password, unsubscribe_newsletter, function hideDeleteAccountPopup() { $("#popup-delete-review").removeClass("popup--fade"); } + +$(document).ready(() => { + $('#edit_account_details_password, #student_account_form').on( + 'click', + '#password-field-icon, #confirm-password-field-icon', + () => { + let inputType; + let dataIcon = $('#password-field-icon').attr('data-icon'); + if (dataIcon === 'material-symbols:visibility') { + inputType = 'password'; + dataIcon = 'material-symbols:visibility-off'; + } else { + inputType = 'text'; + dataIcon = 'material-symbols:visibility'; + } + + $('#id_password').attr('type', inputType); + $('#id_confirm_password').attr('type', inputType); + + $('#password-field-icon').attr('data-icon', dataIcon); + $('#confirm-password-field-icon').attr('data-icon', dataIcon); + } + ); + + $('#edit_account_details_password, #student_account_form').on( + 'click', + '#current-password-field-icon', + () => { + let inputType; + let dataIcon = $('#current-password-field-icon').attr('data-icon'); + if (dataIcon === 'material-symbols:visibility') { + inputType = 'password'; + dataIcon = 'material-symbols:visibility-off'; + } else { + inputType = 'text'; + dataIcon = 'material-symbols:visibility'; + } + + $('#id_current_password').attr('type', inputType); + $('#current-password-field-icon').attr('data-icon', dataIcon); + } + ); + + $('#delete-account, #delete-indy-account').on( + 'click', + '#delete-password-field-icon', + () => { + let inputType; + let dataIcon = $('#delete-password-field-icon').attr('data-icon'); + if (dataIcon === 'material-symbols:visibility') { + inputType = 'password'; + dataIcon = 'material-symbols:visibility-off'; + } else { + inputType = 'text'; + dataIcon = 'material-symbols:visibility'; + } + + $('#id_delete_password').attr('type', inputType); + $('#delete-password-field-icon').attr('data-icon', dataIcon); + } + ); +}); diff --git a/portal/static/portal/js/passwordStrength.js b/portal/static/portal/js/passwordStrength.js index de17330a6..3b3dc0209 100644 --- a/portal/static/portal/js/passwordStrength.js +++ b/portal/static/portal/js/passwordStrength.js @@ -117,10 +117,56 @@ async function handlePwnedPasswordApiAvailability() { } } +function onClickPasswordVisibility( + formId, + passwordIconId, + confirmPasswordIconId, + passwordId, + confirmPasswordId +) { + // Delegate event listeners. + $(formId).on('click', '[data-icon^="material-symbols:visibility"]', function () { + // Get icons and input types. + let inputType; + let dataIcon; + if ($(this).attr('data-icon') === 'material-symbols:visibility') { + inputType = 'password'; + dataIcon = 'material-symbols:visibility-off'; + } else { + inputType = 'text'; + dataIcon = 'material-symbols:visibility'; + } + + // Set icons. + $(passwordIconId).attr('data-icon', dataIcon); + $(confirmPasswordIconId).attr('data-icon', dataIcon); + + // Set input types. + $(passwordId).attr('type', inputType); + $(confirmPasswordId).attr('type', inputType); + }) +} + $(document).ready(function () { handlePasswordStrength(); // the password strength text is updated dynamically hence this is the initial first call handlePwnedPasswordApiAvailability(); $( `#${TEACHER_PASSWORD_FIELD_ID}, #${INDEP_STUDENT_PASSWORD_FIELD_ID}` ).on('input change focus blur', handlePasswordStrength); + + onClickPasswordVisibility( + '#teacher-register-form', + '#teacher-password-field-icon', + '#teacher-confirm-password-field-icon', + '#id_teacher_signup-teacher_password', + '#id_teacher_signup-teacher_confirm_password' + ); + + onClickPasswordVisibility( + '#independent-student-register-form', + '#independent-student-password-field-icon', + '#independent-student-confirm-password-field-icon', + '#id_independent_student_signup-password', + '#id_independent_student_signup-confirm_password' + ); }); diff --git a/portal/static/portal/js/resetPassword.js b/portal/static/portal/js/resetPassword.js new file mode 100644 index 000000000..11aeb195b --- /dev/null +++ b/portal/static/portal/js/resetPassword.js @@ -0,0 +1,23 @@ +$(document).ready(() => { + $('#reset-password-form').on( + 'click', + '#password-field-icon, #confirm-password-field-icon', + () => { + let inputType; + let dataIcon = $('#password-field-icon').attr('data-icon'); + if (dataIcon === 'material-symbols:visibility') { + inputType = 'password'; + dataIcon = 'material-symbols:visibility-off'; + } else { + inputType = 'text'; + dataIcon = 'material-symbols:visibility'; + } + + $('#id_new_password1').attr('type', inputType); + $('#id_new_password2').attr('type', inputType); + + $('#password-field-icon').attr('data-icon', dataIcon); + $('#confirm-password-field-icon').attr('data-icon', dataIcon); + } + ); +}); diff --git a/portal/static/portal/js/studentLogin.js b/portal/static/portal/js/studentLogin.js new file mode 100644 index 000000000..694f4fe23 --- /dev/null +++ b/portal/static/portal/js/studentLogin.js @@ -0,0 +1,16 @@ +$(document).ready(() => { + $('#form-login-school').on('click', '#password-field-icon', () => { + let inputType; + let dataIcon = $('#password-field-icon').attr('data-icon'); + if (dataIcon === 'material-symbols:visibility') { + inputType = 'password'; + dataIcon = 'material-symbols:visibility-off'; + } else { + inputType = 'text'; + dataIcon = 'material-symbols:visibility'; + } + + $('#id_password').attr('type', inputType); + $('#password-field-icon').attr('data-icon', dataIcon); + }); +}); diff --git a/portal/static/portal/js/teacherEditStudent.js b/portal/static/portal/js/teacherEditStudent.js new file mode 100644 index 000000000..b67deacc6 --- /dev/null +++ b/portal/static/portal/js/teacherEditStudent.js @@ -0,0 +1,23 @@ +$(document).ready(() => { + $('#edit-student-password-form').on( + 'click', + '#password-field-icon, #confirm-password-field-icon', + () => { + let inputType; + let dataIcon = $('#password-field-icon').attr('data-icon'); + if (dataIcon === 'material-symbols:visibility') { + inputType = 'password'; + dataIcon = 'material-symbols:visibility-off'; + } else { + inputType = 'text'; + dataIcon = 'material-symbols:visibility'; + } + + $('#id_password').attr('type', inputType); + $('#id_confirm_password').attr('type', inputType); + + $('#password-field-icon').attr('data-icon', dataIcon); + $('#confirm-password-field-icon').attr('data-icon', dataIcon); + } + ); +}); \ No newline at end of file diff --git a/portal/static/portal/js/teacherLogin.js b/portal/static/portal/js/teacherLogin.js new file mode 100644 index 000000000..59a4d687c --- /dev/null +++ b/portal/static/portal/js/teacherLogin.js @@ -0,0 +1,16 @@ +$(document).ready(() => { + $('#form-login-teacher').on('click', '#password-field-icon', () => { + let inputType; + let dataIcon = $('#password-field-icon').attr('data-icon'); + if (dataIcon === 'material-symbols:visibility') { + inputType = 'password'; + dataIcon = 'material-symbols:visibility-off'; + } else { + inputType = 'text'; + dataIcon = 'material-symbols:visibility'; + } + + $('#id_auth-password').attr('type', inputType); + $('#password-field-icon').attr('data-icon', dataIcon); + }); +}); diff --git a/portal/templates/portal/login/independent_student.html b/portal/templates/portal/login/independent_student.html index 7ab16e59b..d631d6c94 100644 --- a/portal/templates/portal/login/independent_student.html +++ b/portal/templates/portal/login/independent_student.html @@ -18,8 +18,10 @@
Please enter your login details.
{{ form.username.errors }} -
- {{ form.password }} +
+
+ {{ form.password }} +
{{ form.password.help_text }} {{ form.password.errors }}
@@ -42,4 +44,5 @@
Please enter your login details.
class="button button--home button--login button-right-arrow">Log in
+ {% endblock form_content %} diff --git a/portal/templates/portal/login/student.html b/portal/templates/portal/login/student.html index fce35e8b4..00d66fcff 100644 --- a/portal/templates/portal/login/student.html +++ b/portal/templates/portal/login/student.html @@ -18,8 +18,10 @@
Please enter your login details.
{{ form.username.errors }} -
- {{ form.password }} +
+
+ {{ form.password }} +
{{ form.password.help_text }} {{ form.password.errors }}
@@ -29,4 +31,5 @@
Please enter your login details.
Log in
+ {% endblock form_content %} diff --git a/portal/templates/portal/login/teacher.html b/portal/templates/portal/login/teacher.html index f567b2ab9..575f7267c 100644 --- a/portal/templates/portal/login/teacher.html +++ b/portal/templates/portal/login/teacher.html @@ -39,8 +39,10 @@
Please enter your login details.
{{ form.username.errors }} -
- {{ form.password }} +
+
+ {{ form.password }} +
{{ form.password.help_text }} {{ form.password.errors }}
@@ -66,4 +68,6 @@
Please enter your login details.
{% include "two_factor/core/login.html" %} {% endif %} + + {% endblock content %} diff --git a/portal/templates/portal/play/student_edit_account.html b/portal/templates/portal/play/student_edit_account.html index 706712d5f..841a87202 100644 --- a/portal/templates/portal/play/student_edit_account.html +++ b/portal/templates/portal/play/student_edit_account.html @@ -80,20 +80,23 @@

Welcome, {{ user|make_into_username }}

{{ form.password }} - +
{{ form.password.help_text }} {{ form.password.errors }}
- {{ form.confirm_password }} +
+ {{ form.confirm_password }} + +
{{ form.confirm_password.help_text }} {{ form.confirm_password.errors }}
{{ form.current_password }} - +
{{ form.current_password.help_text }} {{ form.current_password.errors }} @@ -147,8 +150,8 @@
Delete account
- {{ delete_account_form.delete_password }} - + {{ delete_account_form.delete_password }} +
{{ delete_account_form.delete_password.help_text }} {{ delete_account_form.delete_password.errors }} diff --git a/portal/templates/portal/register.html b/portal/templates/portal/register.html index 786dbcd37..f21529fe8 100644 --- a/portal/templates/portal/register.html +++ b/portal/templates/portal/register.html @@ -6,7 +6,7 @@
-
+

Teacher/Tutor

Register below to create your school or club.

@@ -53,7 +53,7 @@

Teacher/Tutor

- {{ teacher_signup_form.teacher_password }} + {{ teacher_signup_form.teacher_password }}
{{ teacher_signup_form.teacher_password.help_text }} {{ teacher_signup_form.teacher_password.errors }} @@ -61,7 +61,7 @@

Teacher/Tutor

- {{ teacher_signup_form.teacher_confirm_password }} + {{ teacher_signup_form.teacher_confirm_password }}
{{ teacher_signup_form.teacher_confirm_password.help_text }} {{ teacher_signup_form.teacher_confirm_password.errors }} @@ -84,7 +84,7 @@

Teacher/Tutor

-
+

Independent learner

@@ -149,7 +149,7 @@

Independent learner

- {{ independent_student_signup_form.password }} + {{ independent_student_signup_form.password }}
{{ independent_student_signup_form.password.help_text }} {{ independent_student_signup_form.password.errors }} @@ -158,7 +158,7 @@

Independent learner

- {{ independent_student_signup_form.confirm_password }} + {{ independent_student_signup_form.confirm_password }}
{{ independent_student_signup_form.confirm_password.help_text }} {{ independent_student_signup_form.confirm_password.errors }} diff --git a/portal/templates/portal/reset_password_confirm.html b/portal/templates/portal/reset_password_confirm.html index 1de6dd5d0..d175c1df2 100644 --- a/portal/templates/portal/reset_password_confirm.html +++ b/portal/templates/portal/reset_password_confirm.html @@ -8,20 +8,24 @@

Password Reset

{% if validlink %}

Please enter a new password and confirm it in the boxes below to reset your account’s password.

-
+ {% csrf_token %} {{ form.non_field_errors }}
- {{ form.new_password1 }} +
+ {{ form.new_password1 }} +
{{ form.new_password1.help_text }}
{{ form.new_password1.errors }}
- {{ form.new_password2 }} +
+ {{ form.new_password2 }} +
{{ form.new_password2.help_text }}
{{ form.new_password2.errors }} @@ -66,5 +70,6 @@

Password Reset

var INDEP_STUDENT_PASSWORD_FIELD_ID = '{{ form.new_password1.auto_id }}'; + {% endblock form_content %} diff --git a/portal/templates/portal/teach/dashboard.html b/portal/templates/portal/teach/dashboard.html index 360104664..4f91c5fcd 100644 --- a/portal/templates/portal/teach/dashboard.html +++ b/portal/templates/portal/teach/dashboard.html @@ -444,7 +444,7 @@

Your account

{{ update_account_form.password }} - +
{{ update_account_form.password.help_text }} {{ update_account_form.password.errors }} @@ -452,6 +452,7 @@

Your account

{{ update_account_form.confirm_password }} +
{{ update_account_form.confirm_password.help_text }} {{ update_account_form.confirm_password.errors }} @@ -459,7 +460,7 @@

Your account

{{ update_account_form.current_password }} - +
{{ update_account_form.current_password.help_text }} {{ update_account_form.current_password.errors }} @@ -528,7 +529,7 @@
Delete account
{{ delete_account_form.delete_password }} - +
{{ delete_account_form.delete_password.help_text }} {{ delete_account_form.delete_password.errors }} diff --git a/portal/templates/portal/teach/teacher_edit_student.html b/portal/templates/portal/teach/teacher_edit_student.html index 17ee71702..76d6e43f6 100644 --- a/portal/templates/portal/teach/teacher_edit_student.html +++ b/portal/templates/portal/teach/teacher_edit_student.html @@ -1,4 +1,5 @@ {% extends 'portal/base.html' %} +{% load static %} {% block subNav %} {% include "portal/partials/teacher_non_dashboard_subnav.html" %} @@ -39,7 +40,7 @@
Update password

You can set this student's password. Setting the password will also regenerate their direct access link.

- + {% csrf_token %} @@ -49,16 +50,20 @@
Update password
{{ password_form.non_field_errors }}
-
- {{ password_form.password }} +
+
+ {{ password_form.password }} +
{{ password_form.password.errors }} {{ password_form.password.help_text}}
-
- {{ password_form.confirm_password }} +
+
+ {{ password_form.confirm_password }} +
{{ password_form.confirm_password.errors }} {{ password_form.confirm_password.help_text }}
@@ -68,4 +73,6 @@
Update password
+ + {% endblock %}