Browse Source

[Glitch] Show correct error message if chosen password is too long

Port 66baa629ea to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
closed-social-glitch-2
Rens Groothuijsen 2 years ago
committed by Claire
parent
commit
59a5193280
1 changed files with 6 additions and 2 deletions
  1. +6
    -2
      app/javascript/flavours/glitch/packs/public.js

+ 6
- 2
app/javascript/flavours/glitch/packs/public.js View File

@ -99,7 +99,9 @@ function main() {
delegate(document, '#registration_user_password_confirmation,#registration_user_password', 'input', () => { delegate(document, '#registration_user_password_confirmation,#registration_user_password', 'input', () => {
const password = document.getElementById('registration_user_password'); const password = document.getElementById('registration_user_password');
const confirmation = document.getElementById('registration_user_password_confirmation'); const confirmation = document.getElementById('registration_user_password_confirmation');
if (password.value && password.value !== confirmation.value) {
if (confirmation.value && confirmation.value.length > password.maxLength) {
confirmation.setCustomValidity((new IntlMessageFormat(messages['password_confirmation.exceeds_maxlength'] || 'Password confirmation exceeds the maximum password length', locale)).format());
} else if (password.value && password.value !== confirmation.value) {
confirmation.setCustomValidity((new IntlMessageFormat(messages['password_confirmation.mismatching'] || 'Password confirmation does not match', locale)).format()); confirmation.setCustomValidity((new IntlMessageFormat(messages['password_confirmation.mismatching'] || 'Password confirmation does not match', locale)).format());
} else { } else {
confirmation.setCustomValidity(''); confirmation.setCustomValidity('');
@ -111,7 +113,9 @@ function main() {
const confirmation = document.getElementById('user_password_confirmation'); const confirmation = document.getElementById('user_password_confirmation');
if (!confirmation) return; if (!confirmation) return;
if (password.value && password.value !== confirmation.value) {
if (confirmation.value && confirmation.value.length > password.maxLength) {
confirmation.setCustomValidity((new IntlMessageFormat(messages['password_confirmation.exceeds_maxlength'] || 'Password confirmation exceeds the maximum password length', locale)).format());
} else if (password.value && password.value !== confirmation.value) {
confirmation.setCustomValidity((new IntlMessageFormat(messages['password_confirmation.mismatching'] || 'Password confirmation does not match', locale)).format()); confirmation.setCustomValidity((new IntlMessageFormat(messages['password_confirmation.mismatching'] || 'Password confirmation does not match', locale)).format());
} else { } else {
confirmation.setCustomValidity(''); confirmation.setCustomValidity('');

Loading…
Cancel
Save