mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-10 07:55:46 +01:00
Add /me* route which redirects to /user/[userslug]* (#6063)
* Add `/me*` route which redirects to the current user's information - `/me` -> `/user/[usertslug]` - `/me/bookmarks` -> `/user/[userslug]/bookmarks` - `/me/settings` -> `/user/[userslug]/settings` etc * Add tests for `/me/*`
This commit is contained in:
committed by
Barış Soner Uşaklı
parent
643008041c
commit
f5385e38bf
@@ -140,6 +140,22 @@ module.exports = function (middleware) {
|
||||
], next);
|
||||
};
|
||||
|
||||
middleware.redirectMeToUserslug = function (req, res, next) {
|
||||
var uid = req.uid;
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
user.getUserField(uid, 'userslug', next);
|
||||
},
|
||||
function (userslug) {
|
||||
if (!userslug) {
|
||||
return res.status(401).send('not-authorized');
|
||||
}
|
||||
var path = req.path.replace(/^(\/api)?\/me/, '/user/' + userslug);
|
||||
controllers.helpers.redirect(res, path);
|
||||
},
|
||||
], next);
|
||||
};
|
||||
|
||||
middleware.isAdmin = function (req, res, next) {
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
|
||||
Reference in New Issue
Block a user