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

fix: Add password visibility toggle and strength checker to teacher invitation registration form #2372

Merged
merged 6 commits into from
Oct 25, 2024
Merged
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
7 changes: 7 additions & 0 deletions portal/forms/teach.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@


class InvitedTeacherForm(forms.Form):
prefix = 'teacher_signup'

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
for field_name, field in self.fields.items():
field.widget.attrs['id'] = f'id_teacher_signup-{field_name}'

teacher_password = forms.CharField(
help_text="Enter a password",
widget=forms.PasswordInput(
Expand Down
22 changes: 15 additions & 7 deletions portal/templates/portal/teach/invited.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ <h4>Complete registration</h4>
</p>
</div>

<form class="d-flex flex-column" method="post" id="form-invited-teacher" autocomplete="off">
<form class="d-flex flex-column" method="post" id="teacher-register-form" autocomplete="off">

{% csrf_token %}

Expand All @@ -29,15 +29,19 @@ <h4>Complete registration</h4>
<div class="row form--row">
<label for="{{ invited_teacher_form.teacher_password.auto_id }}"></label>
<div class="input--icon">
{{ invited_teacher_form.teacher_password }}<span class="iconify" data-icon="mdi:security"></span>
{{ invited_teacher_form.teacher_password }}
<span id="teacher-password-field-icon" class="iconify"
data-icon="material-symbols:visibility-off" ></span>
</div>
<small>{{ invited_teacher_form.teacher_password.help_text }}</small>
{{ invited_teacher_form.teacher_password.errors }}
</div>
<div class="row form--row">
<label for="{{ invited_teacher_form.teacher_confirm_password.auto_id }}"></label>
<div class="input--icon">
{{ invited_teacher_form.teacher_confirm_password }}<span class="iconify" data-icon="mdi:security"></span>
{{ invited_teacher_form.teacher_confirm_password }}
<span id="teacher-confirm-password-field-icon" class="iconify"
data-icon="material-symbols:visibility-off" ></span>
</div>
<small>{{ invited_teacher_form.teacher_confirm_password.help_text }}</small>
{{ invited_teacher_form.teacher_confirm_password.errors }}
Expand Down Expand Up @@ -73,10 +77,14 @@ <h4>Complete registration</h4>
</div>
</div>

<script type="text/javascript" src="{% static 'portal/js/passwordStrength.js' %}"></script>
{% include "portal/partials/service_unavailable_popup.html" %}

<script>
var TEACHER_PASSWORD_FIELD_ID = '{{ invited_teacher_form.teacher_password.auto_id }}';
var INDEP_STUDENT_PASSWORD_FIELD_ID = '{{ invited_teacher_form.teacher_password.auto_id }}';
const password_id = '{{ invited_teacher_form.teacher_password.auto_id }}';
var TEACHER_PASSWORD_FIELD_ID = password_id;
var INDEP_STUDENT_PASSWORD_FIELD_ID = password_id;
</script>

{% endblock content %}
<script type="text/javascript" src="{% static 'portal/js/passwordStrength.js' %}"></script>

{% endblock content %}
6 changes: 3 additions & 3 deletions portal/tests/test_invite_teacher.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ def test_invite_teacher_successful(self):
response = client.post(
invitation_url,
{
"teacher_password": invited_teacher_password,
"teacher_confirm_password": invited_teacher_password,
"consent_ticked": "on",
"teacher_signup-teacher_password": invited_teacher_password,
"teacher_signup-teacher_confirm_password": invited_teacher_password,
"teacher_signup-consent_ticked": "on",
},
)

Expand Down
Loading