Skip to content

Commit 5a829ee

Browse files
committed
frontend: password reset fixes from code review
1 parent 8ee89c1 commit 5a829ee

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

packages/divbase-api/src/divbase_api/frontend_routes/profile.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ def edit_profile_failed_response(error_message: str):
111111
"request": request,
112112
"current_user": current_user,
113113
"swedish_universities": SWEDISH_UNIVERSITIES,
114+
"known_job_roles": KNOWN_JOB_ROLES,
114115
"name": name,
115116
"organisation": organisation,
116117
"organisation_other": organisation_other,

packages/divbase-api/src/divbase_api/static/js/password_validation.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@ Validates the user password for both registration and password reset:
44
1. Checks that the password and confirm password fields match.
55
2. Checks that the password is not one of the 10,000 most common passwords.
66
3. Min password length specified in HTML inputs
7+
8+
Will prevent form submission if issues.
79
*/
810

911
const passwordInput = document.getElementById('password');
1012
const confirmPasswordInput = document.getElementById('confirm_password');
11-
const registerForm = document.getElementById('registerForm');
13+
const form = document.getElementById("registerForm") || document.getElementById("resetPasswordForm");
14+
1215
let commonPasswords = new Set();
1316

1417
function validatePasswords() {
@@ -35,10 +38,10 @@ async function setupPasswordValidation() {
3538
passwordInput.addEventListener('input', validatePasswords);
3639
confirmPasswordInput.addEventListener('input', validatePasswords);
3740

38-
registerForm.addEventListener('submit', (event) => {
41+
form.addEventListener('submit', (event) => {
3942
validatePasswords();
40-
if (!registerForm.checkValidity()) {
41-
event.preventDefault(); // Stop registration form submission
43+
if (!form.checkValidity()) {
44+
event.preventDefault(); // Stop form submission
4245
}
4346
});
4447

packages/divbase-api/src/divbase_api/templates/auth_pages/reset_password.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ <h4 class="mt-2">Reset Your Password</h4>
1313
<p class="text-muted">Enter your new password for {{ email }}</p>
1414
</div>
1515

16-
<form method="post" action="/reset-password">
16+
<form method="post" action="/reset-password" id="resetPasswordForm">
1717
<input type="hidden" name="token" value="{{ token }}">
1818
<input type="hidden" name="email" value="{{ email }}">
1919

0 commit comments

Comments
 (0)