about summary refs log tree commit diff
path: root/app/javascript
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2020-08-12 12:11:15 +0200
committerThibaut Girka <thib@sitedethib.com>2020-08-13 22:26:22 +0200
commit0f71372d6337f695a87c7158c52b93e49acc215d (patch)
tree882f9cf298e9dffa985f214b28a877b08cf19752 /app/javascript
parentb6c0f1fdc65b98484195279c8f8342bdc5bad747 (diff)
[Glitch] Add client-side validation in password change forms
Port 7dc4c742650ac69ec9a4459b656e172283511e4c to glitch-soc

Signed-off-by: Thibaut Girka <thib@sitedethib.com>
Diffstat (limited to 'app/javascript')
-rw-r--r--app/javascript/flavours/glitch/packs/public.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/app/javascript/flavours/glitch/packs/public.js b/app/javascript/flavours/glitch/packs/public.js
index 8168e87da..b9b588dc6 100644
--- a/app/javascript/flavours/glitch/packs/public.js
+++ b/app/javascript/flavours/glitch/packs/public.js
@@ -105,6 +105,18 @@ function main() {
       }
     });
 
+    delegate(document, '#user_password,#user_password_confirmation', 'input', () => {
+      const password = document.getElementById('user_password');
+      const confirmation = document.getElementById('user_password_confirmation');
+      if (!confirmation) return;
+
+      if (password.value && password.value !== confirmation.value) {
+        confirmation.setCustomValidity((new IntlMessageFormat(messages['password_confirmation.mismatching'] || 'Password confirmation does not match', locale)).format());
+      } else {
+        confirmation.setCustomValidity('');
+      }
+    });
+
     delegate(document, '.custom-emoji', 'mouseover', getEmojiAnimationHandler('data-original'));
     delegate(document, '.custom-emoji', 'mouseout', getEmojiAnimationHandler('data-static'));