ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anovi...@apache.org
Subject ignite git commit: IGNITE-843 Refactor serve to es6.
Date Mon, 15 Feb 2016 10:03:24 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-843-rc2 e2f7d427e -> 53b9b52ee


IGNITE-843 Refactor serve to es6.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/53b9b52e
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/53b9b52e
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/53b9b52e

Branch: refs/heads/ignite-843-rc2
Commit: 53b9b52ee44d0a5a0fe31178da8dd2bb9489d126
Parents: e2f7d42
Author: Andrey <anovikov@gridgain.com>
Authored: Mon Feb 15 17:03:44 2016 +0700
Committer: Andrey <anovikov@gridgain.com>
Committed: Mon Feb 15 17:03:44 2016 +0700

----------------------------------------------------------------------
 .../src/main/js/serve/routes/igfs.js            |  6 +--
 .../src/main/js/serve/routes/profile.js         |  6 +--
 .../src/main/js/serve/routes/public.js          | 41 ++++++++++++--------
 3 files changed, 31 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/53b9b52e/modules/control-center-web/src/main/js/serve/routes/igfs.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/igfs.js b/modules/control-center-web/src/main/js/serve/routes/igfs.js
index 630a75d..78c49b6 100644
--- a/modules/control-center-web/src/main/js/serve/routes/igfs.js
+++ b/modules/control-center-web/src/main/js/serve/routes/igfs.js
@@ -84,9 +84,9 @@ module.exports.factory = function(_, express, mongo) {
             }
             else {
                 mongo.Igfs.findOne({space: params.space, name: params.name}).exec()
-                    .then((_igfs) => {
-                        if (_igfs)
-                            throw new Error('IGFS with name: "' + _igfs + '" already exist.');
+                    .then((igfs) => {
+                        if (igfs)
+                            throw new Error('IGFS with name: "' + igfs + '" already exist.');
 
                         return (new mongo.Igfs(params)).save();
                     })

http://git-wip-us.apache.org/repos/asf/ignite/blob/53b9b52e/modules/control-center-web/src/main/js/serve/routes/profile.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/profile.js b/modules/control-center-web/src/main/js/serve/routes/profile.js
index 079b360..d611df4 100644
--- a/modules/control-center-web/src/main/js/serve/routes/profile.js
+++ b/modules/control-center-web/src/main/js/serve/routes/profile.js
@@ -57,14 +57,14 @@ module.exports.factory = function(_, express, mongo) {
                     if (!params.email || user.email === params.email)
                         return Promise.resolve(user);
 
-                    return new Promise((resolve) => {
+                    return new Promise((resolve, reject) => {
                         mongo.Account.findOne({email: params.email}, (err, _user) => {
                             // TODO send error to admin
                             if (err)
-                                throw new Error('Failed to check e-mail!');
+                                reject(new Error('Failed to check e-mail!'));
 
                             if (_user && _user._id !== user._id)
-                                throw new Error('User with this e-mail already registered!');
+                                reject(new Error('User with this e-mail already registered!'));
 
                             resolve(user);
                         });

http://git-wip-us.apache.org/repos/asf/ignite/blob/53b9b52e/modules/control-center-web/src/main/js/serve/routes/public.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/serve/routes/public.js b/modules/control-center-web/src/main/js/serve/routes/public.js
index 6f78d73..7cbdb8d 100644
--- a/modules/control-center-web/src/main/js/serve/routes/public.js
+++ b/modules/control-center-web/src/main/js/serve/routes/public.js
@@ -71,7 +71,7 @@ module.exports.factory = function(express, passport, nodemailer, settings,
mongo
                     if (err)
                         return reject(sendErrMsg || err.message);
 
-                    resolve();
+                    resolve(user);
                 });
             });
         };
@@ -101,37 +101,45 @@ module.exports.factory = function(express, passport, nodemailer, settings,
mongo
 
                     req.body.token = _randomString();
 
-                    const account = new mongo.Account(req.body);
-
-                    return Promise.resolve(account);
+                    return Promise.resolve(new mongo.Account(req.body));
                 })
                 .then((account) => {
                     return new Promise((resolve, reject) => {
                         mongo.Account.register(account, req.body.password, (err, _account)
=> {
                             if (err)
-                                return reject(err.message);
+                                reject(err);
 
-                            if (!account)
-                                return reject('Failed to create account.');
+                            if (!_account)
+                                reject(new Error('Failed to create account.'));
 
                             resolve(_account);
                         });
                     });
                 })
                 .then((account) => {
+                    return new Promise((resolve, reject) =>
+                        new mongo.Space({name: 'Personal space', owner: account._id}).save()
+                            .then(() => resolve(account))
+                            .catch(reject)
+                    );
+                })
+                .then((account) => {
                     return new Promise((resolve, reject) => {
                         req.logIn(account, {}, (err) => {
                             if (err)
-                                return reject(err.message);
+                                reject(err);
 
                             resolve(account);
                         });
                     });
                 })
-                .then((account) => new mongo.Space({name: 'Personal space', owner: account._id}).save())
-                .then(() => res.sendStatus(200))
-                .catch((errMsg) => {
-                    res.status(401).send(errMsg);
+                .then((account) => {
+                    res.sendStatus(200);
+
+                    //_sendMail(account, '', '');
+                })
+                .catch((err) => {
+                    res.status(401).send(err.message);
                 });
         });
 
@@ -177,14 +185,14 @@ module.exports.factory = function(express, passport, nodemailer, settings,
mongo
 
                     return user.save();
                 })
-                .then((user) => {
-                    return _sendMail(user, 'Password Reset',
+                .then((user) =>
+                    _sendMail(user, 'Password Reset',
                         'You are receiving this because you (or someone else) have requested
the reset of the password for your account.\n\n' +
                         'Please click on the following link, or paste this into your browser
to complete the process:\n\n' +
                         'http://' + req.headers.host + '/password/reset?token=' + user.resetPasswordToken
+ '\n\n' +
                         'If you did not request this, please ignore this email and your password
will remain unchanged.',
-                        'Failed to send e-mail with reset link!');
-                })
+                        'Failed to send e-mail with reset link!')
+                )
                 .then(() => res.status(200).send('An e-mail has been sent with further
instructions.'))
                 .catch((errMsg) => {
                     // TODO IGNITE-843 Send email to admin
@@ -219,6 +227,7 @@ module.exports.factory = function(express, passport, nodemailer, settings,
mongo
                         'Now you can login: http://' + req.headers.host,
                         'Password was changed, but failed to send confirmation e-mail!');
                 })
+                .then((user) => res.status(200).send(user.email))
                 .catch((errMsg) => {
                     res.status(500).send(errMsg);
                 });


Mime
View raw message