From 0159929b672997eaeb33922a6643fa2a69632712 Mon Sep 17 00:00:00 2001 From: Sourav Sahoo Date: Tue, 20 Feb 2018 11:08:16 -0800 Subject: [PATCH] Added initial check for valid email on password reset (#2315) * Added initial check through jquery * Made the code more object oriented * Modified the code according to ES6 rules --- app/assets/javascripts/users.js | 17 +++++++++++++++++ app/views/users/reset.html.erb | 14 +++++++++++--- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/users.js b/app/assets/javascripts/users.js index 322750ea1cc..235f6588250 100644 --- a/app/assets/javascripts/users.js +++ b/app/assets/javascripts/users.js @@ -89,3 +89,20 @@ var Profile = { }); } } + +class Reset { + validateEmail(sEmail){ + const filter = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; + return filter.test(sEmail); + } + + runValidation(event){ + const email = $('#validEmail').val(); + + if(!this.validateEmail(email)) { + $("#validPrint").attr("style", "display:block"); + $("#validPrint").html("

Invalid email address

"); + event.preventDefault(); + } + } +} diff --git a/app/views/users/reset.html.erb b/app/views/users/reset.html.erb index 9d06ebd2808..49bc01cb993 100644 --- a/app/views/users/reset.html.erb +++ b/app/views/users/reset.html.erb @@ -20,17 +20,25 @@ <% else %> -

<%= t('users.reset.enter_email_reset_password') %>:

-
+ + +
- +
<% end %> + +