v1.18.x
barisusakli 9 years ago
parent 77d12deb03
commit 7b86fd3dc0

@ -12,6 +12,7 @@ var categories = require('../categories');
var privileges = require('../privileges');
var plugins = require('../plugins');
var widgets = require('../widgets');
var accountHelpers = require('../controllers/accounts/helpers');
var apiController = {};
@ -218,6 +219,22 @@ apiController.getObject = function(req, res, next) {
});
};
apiController.getCurrentUser = function(req, res, next) {
async.waterfall([
function(next) {
user.getUserField(req.uid, 'userslug', next);
},
function(userslug, next) {
accountHelpers.getUserDataByUserSlug(userslug, req.uid, next);
}
], function(err, userData) {
if (err) {
return next(err);
}
res.json(userData);
});
};
apiController.getUserByUID = function(req, res, next) {
byType('uid', req, res, next);
};

@ -12,6 +12,7 @@ module.exports = function(app, middleware, controllers) {
router.get('/config', middleware.applyCSRF, controllers.api.getConfig);
router.get('/widgets/render', controllers.api.renderWidgets);
router.get('/me', middleware.checkGlobalPrivacySettings, controllers.api.getCurrentUser);
router.get('/user/uid/:uid', middleware.checkGlobalPrivacySettings, controllers.api.getUserByUID);
router.get('/user/username/:username', middleware.checkGlobalPrivacySettings, controllers.api.getUserByUsername);
router.get('/user/email/:email', middleware.checkGlobalPrivacySettings, controllers.api.getUserByEmail);

Loading…
Cancel
Save