You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by se...@apache.org on 2015/07/07 11:58:59 UTC

incubator-ignite git commit: IGNITE-843 First user must be admin.

Repository: incubator-ignite
Updated Branches:
  refs/heads/ignite-843 1a71cbad4 -> 047c41b02


IGNITE-843 First user must be admin.


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

Branch: refs/heads/ignite-843
Commit: 047c41b0235ccdbb146a79a7d5b15de95af022e3
Parents: 1a71cba
Author: sevdokimov <se...@jetbrains.com>
Authored: Tue Jul 7 12:58:53 2015 +0300
Committer: sevdokimov <se...@jetbrains.com>
Committed: Tue Jul 7 12:58:53 2015 +0300

----------------------------------------------------------------------
 .../web-control-center/nodejs/routes/auth.js    | 21 +++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/047c41b0/modules/web-control-center/nodejs/routes/auth.js
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/routes/auth.js b/modules/web-control-center/nodejs/routes/auth.js
index fd018ab..a0ec132 100644
--- a/modules/web-control-center/nodejs/routes/auth.js
+++ b/modules/web-control-center/nodejs/routes/auth.js
@@ -24,20 +24,27 @@ var db = require('../db');
  * Register new account.
  */
 router.post('/register', function(req, res, next) {
-    db.Account.register(new db.Account(req.body), req.body.password, function(err, account) {
+    db.Account.count(function (err, cnt) {
         if (err)
             return res.status(401).send(err.message);
 
-        if (!account)
-            return res.status(500).send('Failed to create account.');
+        req.body.admin = cnt == 0;
 
-        new db.Space({name: 'Personal space', owner: account._id}).save();
-
-        req.logIn(account, {}, function(err) {
+        db.Account.register(new db.Account(req.body), req.body.password, function(err, account) {
             if (err)
                 return res.status(401).send(err.message);
 
-            return res.redirect('/configuration/clusters');
+            if (!account)
+                return res.status(500).send('Failed to create account.');
+
+            new db.Space({name: 'Personal space', owner: account._id}).save();
+
+            req.logIn(account, {}, function(err) {
+                if (err)
+                    return res.status(401).send(err.message);
+
+                return res.redirect('/configuration/clusters');
+            });
         });
     });
 });