You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by an...@apache.org on 2015/08/17 10:10:52 UTC
[2/3] incubator-ignite git commit: # IGNITE-843 Cleanup forgot
password.
# IGNITE-843 Cleanup forgot password.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/7d5299e8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/7d5299e8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/7d5299e8
Branch: refs/heads/ignite-843
Commit: 7d5299e8cf026b2af0dd32506f5691ade6112a4e
Parents: facf9b6
Author: Andrey <an...@gridgain.com>
Authored: Mon Aug 17 15:10:29 2015 +0700
Committer: Andrey <an...@gridgain.com>
Committed: Mon Aug 17 15:10:29 2015 +0700
----------------------------------------------------------------------
.../src/main/js/routes/public.js | 57 +++++++++++++++++++-
.../src/main/js/views/login.jade | 31 ++++++-----
2 files changed, 74 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7d5299e8/modules/control-center-web/src/main/js/routes/public.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/routes/public.js b/modules/control-center-web/src/main/js/routes/public.js
index ef00f56..e29c7e6 100644
--- a/modules/control-center-web/src/main/js/routes/public.js
+++ b/modules/control-center-web/src/main/js/routes/public.js
@@ -112,9 +112,9 @@ router.get('/logout', function (req, res) {
});
/**
- * Request for password reset and send e-mail to user with reset token.
+ * Send e-mail to user with reset token.
*/
-router.post('/request_password_reset', function(req, res) {
+router.post('/forgot_password', function(req, res) {
var transporter = {
service: config.get('smtp:service'),
auth: {
@@ -166,6 +166,59 @@ router.post('/request_password_reset', function(req, res) {
});
});
+/**
+ * Change password with given token.
+ */
+router.post('/reset_password', function(req, res) {
+ db.Account.findOne({ resetPasswordToken: req.body.token }, function(err, user) {
+ if (!user)
+ return res.status(500).send('Invalid token for password reset!');
+
+ if (err)
+ return res.status(500).send(err);
+
+ user.setPassword(req.body.password, function (err, updatedUser) {
+ if (err)
+ return res.status(500).send(err.message);
+
+ updatedUser.resetPasswordToken = undefined;
+
+ updatedUser.save(function (err) {
+ if (err)
+ return res.status(500).send(err.message);
+
+ var transporter = {
+ service: config.get('smtp:service'),
+ auth: {
+ user: config.get('smtp:username'),
+ pass: config.get('smtp:password')
+ }
+ };
+
+ var mailer = nodemailer.createTransport(transporter);
+
+ var mailOptions = {
+ from: transporter.auth.user,
+ to: user.email,
+ subject: 'Your password has been changed',
+ text: 'Hello,\n\n' +
+ 'This is a confirmation that the password for your account ' + user.email + ' has just been changed.\n\n' +
+ 'Now you can login: http://' + req.headers.host + '\n\n' +
+ '--------------\n' +
+ 'Apache Ignite Web Control Center\n'
+ };
+
+ mailer.sendMail(mailOptions, function (err) {
+ if (err)
+ return res.status(503).send('Password was changed, but failed to send confirmation e-mail!<br />' + err);
+
+ return res.status(200).send(user.email);
+ });
+ });
+ });
+ });
+});
+
router.get('/reset', function (req, res) {
res.render('reset', {});
});
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7d5299e8/modules/control-center-web/src/main/js/views/login.jade
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/views/login.jade b/modules/control-center-web/src/main/js/views/login.jade
index 19979e2..90af007 100644
--- a/modules/control-center-web/src/main/js/views/login.jade
+++ b/modules/control-center-web/src/main/js/views/login.jade
@@ -28,7 +28,9 @@ mixin lbl(txt)
p(style='padding-right: 55px') Log in or register in order to collaborate
form.form-horizontal(name='loginForm' ng-init='action == "login"')
.modal-body.row
- .col-sm-9.col-sm-offset-1
+ .col-sm-10.col-sm-offset-1
+ p(ng-show='action == "forgot_password"')
+ | That's ok! Simply enter your email below and a reset password link will be sent to you via email. You can then follow that link and select a new password.
.details-row(ng-show='action == "register"')
+lbl('Full Name:')
.col-sm-9
@@ -36,20 +38,25 @@ mixin lbl(txt)
.details-row
+lbl('Email:')
.col-sm-9
- input#user_email.form-control(enter-focus-next='user_password' type='email' ng-model='user_info.email' placeholder='you@domain.com' required on-enter='action == "request_password_reset" && loginForm.$valid && auth(action, user_info)')
- .details-row(ng-show='action != "request_password_reset"')
+ input#user_email.form-control(enter-focus-next='user_password' type='email' ng-model='user_info.email' placeholder='you@domain.com' required on-enter='action == "forgot_password" && loginForm.$valid && auth(action, user_info)')
+ .details-row(ng-show='action != "forgot_password"')
+lbl('Password:')
.col-sm-9
- input#user_password.form-control(enter-focus-next='user_confirm' type='password' ng-model='user_info.password' placeholder='Password' ng-required='action != "request_password_reset"' on-enter='action == "login" && loginForm.$valid && auth(action, user_info)')
+ input#user_password.form-control(enter-focus-next='user_confirm' type='password' ng-model='user_info.password' placeholder='Password' ng-required='action != "forgot_password"' on-enter='action == "login" && loginForm.$valid && auth(action, user_info)')
.details-row(ng-if='action == "register"')
+lbl('Confirm:')
.col-sm-9
input#user_confirm.form-control(type='password' ng-model='user_info.confirm' match='user_info.password' placeholder='Confirm password' ng-required='action == "register"' on-enter='loginForm.$valid && auth(action, user_info)')
- .modal-footer
- a.labelField(ng-show='action != "request_password_reset"' ng-click='action = "request_password_reset"' on-click-focus='user_email') Forgot password?
- a.labelField(ng-show='action == "request_password_reset"' ng-click='action = "login"' on-click-focus='user_email') Log In
- a.labelLogin(ng-show='action == "register"' on-click-focus='user_email' ng-click='action = "login";') Log In
- a.labelLogin(ng-show='action == "login"' on-click-focus='user_name' ng-click='action = "register"') Sign Up
- button.btn.btn-primary(ng-show='action == "login"' ng-disabled='loginForm.$invalid' ng-click='auth(action, user_info)') Log In
- button.btn.btn-primary(ng-show='action == "register"' ng-disabled='loginForm.$invalid' ng-click='auth(action, user_info)') Sign Up
- button.btn.btn-primary(ng-show='action == "request_password_reset"' ng-disabled='loginForm.$invalid' ng-click='auth(action, user_info)') Reset Password
+ .modal-footer(ng-show='action == "register"')
+ a.labelField(ng-click='action = "forgot_password"' on-click-focus='user_email') Forgot password?
+ a.labelLogin(ng-click='action = "login";' on-click-focus='user_email') Log In
+ button.btn.btn-primary(ng-click='auth(action, user_info)' ng-disabled='loginForm.$invalid') Sign Up
+
+ .modal-footer(ng-show='action == "forgot_password"')
+ a.labelField(ng-click='action = "login"' on-click-focus='user_email') Log In
+ button.btn.btn-primary(ng-click='auth(action, user_info)' ng-disabled='loginForm.$invalid') Send it to me
+
+ .modal-footer(ng-show='action == "login"')
+ a.labelField(ng-click='action = "forgot_password"' on-click-focus='user_email') Forgot password?
+ a.labelLogin(ng-click='action = "register"' on-click-focus='user_name') Sign Up
+ button.btn.btn-primary(ng-click='auth(action, user_info)' ng-disabled='loginForm.$invalid') Log In
\ No newline at end of file