mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-06 22:15:48 +01:00
This commit is contained in:
@@ -77,6 +77,15 @@ middleware.redirectToAccountIfLoggedIn = function(req, res, next) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
middleware.redirectToLoginIfGuest = function(req, res, next) {
|
||||||
|
if (!req.user || parseInt(req.user.uid, 10) === 0) {
|
||||||
|
req.session.returnTo = req.url;
|
||||||
|
return res.redirect('/login');
|
||||||
|
} else {
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
middleware.addSlug = function(req, res, next) {
|
middleware.addSlug = function(req, res, next) {
|
||||||
function redirect(method, id, name) {
|
function redirect(method, id, name) {
|
||||||
method(id, 'slug', function(err, slug) {
|
method(id, 'slug', function(err, slug) {
|
||||||
|
|||||||
@@ -117,8 +117,8 @@ function accountRoutes(app, middleware, controllers) {
|
|||||||
app.get('/notifications', middleware.buildHeader, middleware.authenticate, controllers.accounts.getNotifications);
|
app.get('/notifications', middleware.buildHeader, middleware.authenticate, controllers.accounts.getNotifications);
|
||||||
app.get('/api/notifications', middleware.authenticate, controllers.accounts.getNotifications);
|
app.get('/api/notifications', middleware.authenticate, controllers.accounts.getNotifications);
|
||||||
|
|
||||||
app.get('/chats/:userslug?', middleware.buildHeader, middleware.authenticate, controllers.accounts.getChats);
|
app.get('/chats/:userslug?', middleware.buildHeader, middleware.redirectToLoginIfGuest, controllers.accounts.getChats);
|
||||||
app.get('/api/chats/:userslug?', middleware.authenticate, controllers.accounts.getChats);
|
app.get('/api/chats/:userslug?', middleware.redirectToLoginIfGuest, controllers.accounts.getChats);
|
||||||
}
|
}
|
||||||
|
|
||||||
function userRoutes(app, middleware, controllers) {
|
function userRoutes(app, middleware, controllers) {
|
||||||
|
|||||||
Reference in New Issue
Block a user