From 1c733389b6292b1b65bfa0d4b00d6ee45412dc37 Mon Sep 17 00:00:00 2001 From: Salil-Jain Date: Tue, 17 Jul 2018 00:49:02 +0530 Subject: [PATCH 01/10] basic implementation of change password done --- client/styles/global.scss | 6 ++-- client/views/login/login.html | 3 ++ client/views/login/login.js | 10 ++++++ client/views/resetpwd/resetpwd.html | 33 +++++++++++++++++++ client/views/resetpwd/resetpwd.js | 50 +++++++++++++++++++++++++++++ lib/routes.js | 9 ++++++ server/lib/startup.js | 7 +++- 7 files changed, 114 insertions(+), 4 deletions(-) create mode 100644 client/views/resetpwd/resetpwd.html create mode 100644 client/views/resetpwd/resetpwd.js diff --git a/client/styles/global.scss b/client/styles/global.scss index 07fa29e7..1e5b847f 100644 --- a/client/styles/global.scss +++ b/client/styles/global.scss @@ -93,7 +93,7 @@ a { } } -#loginsubmitbutton { +#loginsubmitbutton, #registersubmitbutton, #forgotsubmitbutton, #newpwdsubmitbutton { width: 40%; display: block; height: 30px; @@ -113,7 +113,7 @@ a { } } -#registersubmitbutton { +/*#registersubmitbutton { width: 40%; display: block; height: 30px; @@ -131,7 +131,7 @@ a { &:hover { background-color: #4cd785; } -} +}*/ #shareclosebutton { width: 40%; diff --git a/client/views/login/login.html b/client/views/login/login.html index 055dcd3e..c36945f9 100644 --- a/client/views/login/login.html +++ b/client/views/login/login.html @@ -12,6 +12,9 @@

Login

Don't have an account?

Register

+

+ Forgot Password +

Login diff --git a/client/views/login/login.js b/client/views/login/login.js index f6451621..c69ceac3 100644 --- a/client/views/login/login.js +++ b/client/views/login/login.js @@ -42,6 +42,16 @@ Template.login.events({ }, 10); }); }, + 'click #forgotemphasis': function (event, template) { + $('.formcontainer').fadeOut(400); + $('#darker').fadeOut(400, () => { + Blaze.remove(popoverTemplate); + window.setTimeout(() => { + const parentNode = document.getElementById('nav'); + popoverTemplate = Blaze.render(Template.resetpwd, parentNode); + }, 10); + }); + }, 'keypress #passwordbox': function (event, template) { // eslint-disable-next-line no-param-reassign event.which = event.which || event.keyCode; diff --git a/client/views/resetpwd/resetpwd.html b/client/views/resetpwd/resetpwd.html new file mode 100644 index 00000000..754bb9b6 --- /dev/null +++ b/client/views/resetpwd/resetpwd.html @@ -0,0 +1,33 @@ + \ No newline at end of file diff --git a/client/views/resetpwd/resetpwd.js b/client/views/resetpwd/resetpwd.js new file mode 100644 index 00000000..d2892cba --- /dev/null +++ b/client/views/resetpwd/resetpwd.js @@ -0,0 +1,50 @@ +Accounts.onResetPasswordLink((token, done) => { + setTimeout(()=>Router.go("resetpwd"), 0); +}) + +if (Accounts._resetPasswordToken) { + Session.set('resetPasswordVar', Accounts._resetPasswordToken); +} + +function showError(reason, parentElement, nextElement) { + if (typeof currentError !== 'undefined') { + Blaze.remove(currentError); + } + const parentNode = document.getElementsByClassName(parentElement)[0]; + const nextNode = document.getElementById(nextElement); + currentError = Blaze.renderWithData(Template.form_error, reason, parentNode, nextNode); +} + +Template.resetpwd.onRendered(() => { + $('.formcontainer').hide().fadeIn(400); + $('#darker').hide().fadeIn(400); +}); + +Template.resetpwd.helpers({ + resetPassword() { + return Session.get('resetPasswordVar'); + } +}); + +Template.resetpwd.events({ + 'click #forgotsubmitbutton': function (event, template) { + email = document.getElementById('loginemail').value; + Accounts.forgotPassword({email: email}, function (e) { + if (e) { + console.log("Error in forgot password: ", e.reason); + } else { + console.log("Success"); + } + }); + }, + 'click #newpwdsubmitbutton': function (event, template) { + const newPass = document.getElementById('newpasswordbox').value; + Accounts.resetPassword(Session.get('resetPasswordVar'), newPass, function (e) { + if (e) { + console.log("Error in changing password: ", e.reason); + } else { + console.log("Password changed."); + } + }); + }, +}); diff --git a/lib/routes.js b/lib/routes.js index 2a5f6b0a..b0d43a2e 100644 --- a/lib/routes.js +++ b/lib/routes.js @@ -201,3 +201,12 @@ Router.route('/rss/:tablename', { this.response.end(xmlData); }, }); + +// When user clicks on reset password link from their email +// Router.route('/#/reset-password/:token', { +// name: 'resetpwd', +// template: 'resetpwd', +// }); +Router.route('resetpwd', { + template: 'resetpwd', +}); \ No newline at end of file diff --git a/server/lib/startup.js b/server/lib/startup.js index 5e93c22b..cce72ffd 100644 --- a/server/lib/startup.js +++ b/server/lib/startup.js @@ -2,7 +2,12 @@ Meteor.startup(() => { // Email of Question Tool super admin. Has control over Instances, etc. process.env.SUPERADMIN_EMAIL = 'questiontool@admin.com'; // URL of mail server goes here for email sending - process.env.MAIL_URL = 'http://localhost:3000/'; + process.env.MAIL_URL = 'http://localhost:3000'; + //'smtp://user:password@mailhost:port/' + + // Accounts.urls.resetPassword = function(token) { + // return Meteor.absoluteUrl('reset-password/' + token); + // }; SyncedCron.start(); }); From f72f48c634a0cb288a0fc15c42ebdcffc128c626 Mon Sep 17 00:00:00 2001 From: Salil-Jain Date: Wed, 18 Jul 2018 19:24:14 +0530 Subject: [PATCH 02/10] Almost done --- client/styles/global.scss | 2 +- client/views/login/login.html | 1 + client/views/resetpwd/resetpwd.html | 25 ++++++----- client/views/resetpwd/resetpwd.js | 50 +++++++++++++++++++-- client/views/resetpwd/resetpwd.scss | 67 +++++++++++++++++++++++++++++ server/lib/startup.js | 2 +- 6 files changed, 131 insertions(+), 16 deletions(-) create mode 100644 client/views/resetpwd/resetpwd.scss diff --git a/client/styles/global.scss b/client/styles/global.scss index 1e5b847f..87201343 100644 --- a/client/styles/global.scss +++ b/client/styles/global.scss @@ -93,7 +93,7 @@ a { } } -#loginsubmitbutton, #registersubmitbutton, #forgotsubmitbutton, #newpwdsubmitbutton { +#loginsubmitbutton, #registersubmitbutton, #forgotsubmitbutton { width: 40%; display: block; height: 30px; diff --git a/client/views/login/login.html b/client/views/login/login.html index c36945f9..0c7824be 100644 --- a/client/views/login/login.html +++ b/client/views/login/login.html @@ -12,6 +12,7 @@

Login

Don't have an account?

Register

+

Forgot Password

diff --git a/client/views/resetpwd/resetpwd.html b/client/views/resetpwd/resetpwd.html index 754bb9b6..b117c1ef 100644 --- a/client/views/resetpwd/resetpwd.html +++ b/client/views/resetpwd/resetpwd.html @@ -1,19 +1,22 @@