use middleware.authenticate instead of checking in each fn

v1.18.x
psychobunny 11 years ago
parent 01cda60704
commit 0bbff06cfa

@ -251,10 +251,6 @@ adminController.uploads.uploadImage = function(filename, req, res) {
}; };
adminController.uploads.uploadCategoryPicture = function(req, res, next) { adminController.uploads.uploadCategoryPicture = function(req, res, next) {
if (!req.user) {
return res.redirect('/403');
}
var allowedTypes = ['image/png', 'image/jpeg', 'image/jpg', 'image/gif'], var allowedTypes = ['image/png', 'image/jpeg', 'image/jpg', 'image/gif'],
params = null, er; params = null, er;
try { try {
@ -280,10 +276,6 @@ adminController.uploads.uploadCategoryPicture = function(req, res, next) {
}; };
adminController.uploads.uploadFavicon = function(req, res, next) { adminController.uploads.uploadFavicon = function(req, res, next) {
if (!req.user) {
return res.redirect('/403');
}
var allowedTypes = ['image/x-icon', 'image/vnd.microsoft.icon'], var allowedTypes = ['image/x-icon', 'image/vnd.microsoft.icon'],
er; er;
@ -307,10 +299,6 @@ adminController.uploads.uploadFavicon = function(req, res, next) {
}; };
adminController.uploads.uploadLogo = function(req, res, next) { adminController.uploads.uploadLogo = function(req, res, next) {
if (!req.user) {
return res.redirect('/403');
}
var allowedTypes = ['image/png', 'image/jpeg', 'image/pjpeg', 'image/jpg', 'image/gif'], var allowedTypes = ['image/png', 'image/jpeg', 'image/pjpeg', 'image/jpg', 'image/gif'],
er; er;

@ -52,11 +52,11 @@ function forumRoutes(app, middleware, controllers) {
function apiRoutes(app, middleware, controllers) { function apiRoutes(app, middleware, controllers) {
// todo, needs to be in api namespace // todo, needs to be in api namespace
app.get('/admin/users/csv', controllers.admin.users.getCSV); app.get('/admin/users/csv', middleware.authenticate, controllers.admin.users.getCSV);
app.post('/admin/category/uploadpicture', controllers.admin.uploads.uploadCategoryPicture); app.post('/admin/category/uploadpicture', middleware.authenticate, controllers.admin.uploads.uploadCategoryPicture);
app.post('/admin/uploadfavicon', controllers.admin.uploads.uploadFavicon); app.post('/admin/uploadfavicon', middleware.authenticate, controllers.admin.uploads.uploadFavicon);
app.post('/admin/uploadlogo', controllers.admin.uploads.uploadLogo); app.post('/admin/uploadlogo', middleware.authenticate, controllers.admin.uploads.uploadLogo);
} }
function miscRoutes(app, middleware, controllers) { function miscRoutes(app, middleware, controllers) {

Loading…
Cancel
Save