diff options
Diffstat (limited to 'server/controllers/api/users.js')
-rw-r--r-- | server/controllers/api/users.js | 18 |
1 files changed, 2 insertions, 16 deletions
diff --git a/server/controllers/api/users.js b/server/controllers/api/users.js index 53bf56790..6cd0e84f7 100644 --- a/server/controllers/api/users.js +++ b/server/controllers/api/users.js | |||
@@ -6,6 +6,7 @@ const waterfall = require('async/waterfall') | |||
6 | const constants = require('../../initializers/constants') | 6 | const constants = require('../../initializers/constants') |
7 | const db = require('../../initializers/database') | 7 | const db = require('../../initializers/database') |
8 | const logger = require('../../helpers/logger') | 8 | const logger = require('../../helpers/logger') |
9 | const utils = require('../../helpers/utils') | ||
9 | const middlewares = require('../../middlewares') | 10 | const middlewares = require('../../middlewares') |
10 | const admin = middlewares.admin | 11 | const admin = middlewares.admin |
11 | const oAuth = middlewares.oauth | 12 | const oAuth = middlewares.oauth |
@@ -82,7 +83,7 @@ function listUsers (req, res, next) { | |||
82 | db.User.listForApi(req.query.start, req.query.count, req.query.sort, function (err, usersList, usersTotal) { | 83 | db.User.listForApi(req.query.start, req.query.count, req.query.sort, function (err, usersList, usersTotal) { |
83 | if (err) return next(err) | 84 | if (err) return next(err) |
84 | 85 | ||
85 | res.json(getFormatedUsers(usersList, usersTotal)) | 86 | res.json(utils.getFormatedObjects(usersList, usersTotal)) |
86 | }) | 87 | }) |
87 | } | 88 | } |
88 | 89 | ||
@@ -121,18 +122,3 @@ function updateUser (req, res, next) { | |||
121 | function success (req, res, next) { | 122 | function success (req, res, next) { |
122 | res.end() | 123 | res.end() |
123 | } | 124 | } |
124 | |||
125 | // --------------------------------------------------------------------------- | ||
126 | |||
127 | function getFormatedUsers (users, usersTotal) { | ||
128 | const formatedUsers = [] | ||
129 | |||
130 | users.forEach(function (user) { | ||
131 | formatedUsers.push(user.toFormatedJSON()) | ||
132 | }) | ||
133 | |||
134 | return { | ||
135 | total: usersTotal, | ||
136 | data: formatedUsers | ||
137 | } | ||
138 | } | ||