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/15 21:16:57 UTC
[09/45] incubator-ignite git commit: # ignite-843 Cleanup user on
client side, fixed profile.
# ignite-843 Cleanup user on client side, fixed profile.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/a7efd5d7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/a7efd5d7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/a7efd5d7
Branch: refs/heads/ignite-1121
Commit: a7efd5d7c7a42b4a4566ca0be8def27afc29f766
Parents: f7d1aa8
Author: Andrey <an...@gridgain.com>
Authored: Tue Jul 14 11:36:43 2015 +0700
Committer: Andrey <an...@gridgain.com>
Committed: Tue Jul 14 11:36:43 2015 +0700
----------------------------------------------------------------------
.../nodejs/controllers/profile-controller.js | 12 ++++----
modules/web-control-center/nodejs/db.js | 3 +-
.../nodejs/helpers/ui-utils.js | 29 --------------------
.../web-control-center/nodejs/routes/admin.js | 2 +-
.../web-control-center/nodejs/routes/profile.js | 9 +++---
.../nodejs/views/templates/layout.jade | 2 +-
6 files changed, 14 insertions(+), 43 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a7efd5d7/modules/web-control-center/nodejs/controllers/profile-controller.js
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/controllers/profile-controller.js b/modules/web-control-center/nodejs/controllers/profile-controller.js
index 6579d8d..ccb2b01 100644
--- a/modules/web-control-center/nodejs/controllers/profile-controller.js
+++ b/modules/web-control-center/nodejs/controllers/profile-controller.js
@@ -16,17 +16,17 @@
*/
controlCenterModule.controller('profileController', ['$scope', '$http', 'commonFunctions', function ($scope, $http, commonFunctions) {
- $scope.profileUser = angular.copy($scope.loggedInUser);
+ $scope.profileUser = angular.copy($scope.user);
$scope.saveUser = function() {
var profile = $scope.profileUser;
if (profile) {
var userName = profile.username;
- var changeUsername = userName != $scope.loggedInUser.username;
+ var changeUsername = userName != $scope.user.username;
var email = profile.email;
- var changeEmail = email != $scope.loggedInUser.email;
+ var changeEmail = email != $scope.user.email;
if (changeUsername || changeEmail || profile.changePassword) {
$http.post('/profile/saveUser', {
@@ -34,14 +34,14 @@ controlCenterModule.controller('profileController', ['$scope', '$http', 'commonF
userName: changeUsername ? userName : undefined,
email: changeEmail ? email : undefined,
newPassword: profile.changePassword ? profile.newPassword : undefined
- }).success(function () {
+ }).success(function (user) {
commonFunctions.showInfo('Profile saved.');
if (changeUsername)
- $scope.loggedInUser.username = userName;
+ $scope.user.username = userName;
if (changeEmail)
- $scope.loggedInUser.email = email;
+ $scope.user.email = email;
}).error(function (err) {
commonFunctions.showError('Failed to save profile: ' + commonFunctions.errorMessage(err));
});
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a7efd5d7/modules/web-control-center/nodejs/db.js
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/db.js b/modules/web-control-center/nodejs/db.js
index 101d4ae..2b64daf 100644
--- a/modules/web-control-center/nodejs/db.js
+++ b/modules/web-control-center/nodejs/db.js
@@ -34,7 +34,8 @@ var AccountSchema = new Schema({
admin: Boolean
});
-AccountSchema.plugin(passportLocalMongoose, {usernameField: 'email', limitAttempts: true, lastLoginField: 'lastLogin', usernameLowerCase: true});
+AccountSchema.plugin(passportLocalMongoose, {usernameField: 'email', limitAttempts: true, lastLoginField: 'lastLogin',
+ usernameLowerCase: true});
exports.Account = mongoose.model('Account', AccountSchema);
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a7efd5d7/modules/web-control-center/nodejs/helpers/ui-utils.js
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/helpers/ui-utils.js b/modules/web-control-center/nodejs/helpers/ui-utils.js
deleted file mode 100644
index e9e680b..0000000
--- a/modules/web-control-center/nodejs/helpers/ui-utils.js
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-exports.filterUser = function (user) {
- if (!user)
- return null;
-
- return {
- _id: user._id,
- username: user.username,
- lastLogin: user.lastLogin,
- admin: user.admin,
- email: user.email
- }
-};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a7efd5d7/modules/web-control-center/nodejs/routes/admin.js
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/routes/admin.js b/modules/web-control-center/nodejs/routes/admin.js
index f1625e3..57c8e6f 100644
--- a/modules/web-control-center/nodejs/routes/admin.js
+++ b/modules/web-control-center/nodejs/routes/admin.js
@@ -26,7 +26,7 @@ router.get('/', function(req, res) {
* Get list of user accounts.
*/
router.post('/list', function(req, res) {
- db.Account.find({}).select('_id username email lastLogin admin').exec(function (err, users) {
+ db.Account.find({}).select('-attempts -hash -salt').exec(function (err, users) {
if (err)
return res.status(500).send(err.message);
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a7efd5d7/modules/web-control-center/nodejs/routes/profile.js
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/routes/profile.js b/modules/web-control-center/nodejs/routes/profile.js
index 5caae0b..7051eb6 100644
--- a/modules/web-control-center/nodejs/routes/profile.js
+++ b/modules/web-control-center/nodejs/routes/profile.js
@@ -17,7 +17,6 @@
var router = require('express').Router();
var db = require('../db');
-var uiUtils = require('../helpers/ui-utils');
router.all('/profile/*', function (req, res, next) {
var userId = req.body._id;
@@ -54,7 +53,7 @@ router.post('/saveUser', function (req, res) {
if (!newPassword || newPassword.length == 0)
return res.status(500).send('Wrong value for new password');
- db.Account.findById(params._id, function (err, user) {
+ db.Account.findById(params._id).select('-attempts -hash -salt').exec(function (err, user) {
if (err)
return res.status(500).send(err);
@@ -72,7 +71,7 @@ router.post('/saveUser', function (req, res) {
if (err)
return res.status(500).send(err.message);
- res.json(uiUtils.filterUser(user));
+ res.json(user);
});
});
});
@@ -86,11 +85,11 @@ router.post('/saveUser', function (req, res) {
if (params.email)
upd.email = params.email;
- db.Account.findByIdAndUpdate(params._id, upd, {new: true}, function (err, val) {
+ db.Account.findByIdAndUpdate(params._id, upd, {new: true}).select('-attempts -hash -salt').exec(function (err, val) {
if (err)
return res.status(500).send(err.message);
- res.json(uiUtils.filterUser(val));
+ res.json(val);
})
}
});
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/a7efd5d7/modules/web-control-center/nodejs/views/templates/layout.jade
----------------------------------------------------------------------
diff --git a/modules/web-control-center/nodejs/views/templates/layout.jade b/modules/web-control-center/nodejs/views/templates/layout.jade
index e7adc8c..f9ec5d6 100644
--- a/modules/web-control-center/nodejs/views/templates/layout.jade
+++ b/modules/web-control-center/nodejs/views/templates/layout.jade
@@ -15,7 +15,7 @@
limitations under the License.
doctype html
-html(ng-app='ignite-web-control-center', ng-init='user = #{JSON.stringify(filterUser(user))}; becomeUsed = #{becomeUsed}')
+html(ng-app='ignite-web-control-center', ng-init='user = #{JSON.stringify(user)}; becomeUsed = #{becomeUsed}')
head
title= title