|
|
@ -1,16 +1,15 @@
|
|
|
|
import DateUtils from '../../tools/utilities/DateUtils';
|
|
|
|
import DateUtils from '../../utils/tools/DateUtils';
|
|
|
|
import * as DataEvent from '../../tools/events/DataEvent';
|
|
|
|
import * as DataEvent from '../../utils/events/DataEvent';
|
|
|
|
import RightsManager, {
|
|
|
|
import RightsManager, {
|
|
|
|
TASK_CREATE,
|
|
|
|
TASK_CREATE,
|
|
|
|
TASK_UPDATE,
|
|
|
|
TASK_UPDATE,
|
|
|
|
OBJECT_POST,
|
|
|
|
OBJECT_POST,
|
|
|
|
OBJECT_SETTINGS
|
|
|
|
OBJECT_SETTINGS
|
|
|
|
} from '../../tools/utilities/RightsManager';
|
|
|
|
} from '../../utils/tools/RightsManager';
|
|
|
|
const express = require('express');
|
|
|
|
const express = require('express');
|
|
|
|
const router = express.Router();
|
|
|
|
const router = express.Router();
|
|
|
|
const multer = require('multer');
|
|
|
|
const multer = require('multer');
|
|
|
|
const fs = require('fs-extra');
|
|
|
|
const fs = require('fs-extra');
|
|
|
|
const Models = require('../../models');
|
|
|
|
|
|
|
|
const dateUtils = new DateUtils();
|
|
|
|
const dateUtils = new DateUtils();
|
|
|
|
const rightsManager = new RightsManager();
|
|
|
|
const rightsManager = new RightsManager();
|
|
|
|
const uploadPath =
|
|
|
|
const uploadPath =
|
|
|
@ -40,7 +39,6 @@ var background_upload = multer({
|
|
|
|
//** SYNC POSTS */
|
|
|
|
//** SYNC POSTS */
|
|
|
|
router.post('/sync', (req, res) => {
|
|
|
|
router.post('/sync', (req, res) => {
|
|
|
|
let payload = req.body;
|
|
|
|
let payload = req.body;
|
|
|
|
Models.User.findById(req.session.user.id).then(user => {
|
|
|
|
|
|
|
|
if (rightsManager.check(user.role, OBJECT_SETTINGS, TASK_UPDATE)) {
|
|
|
|
if (rightsManager.check(user.role, OBJECT_SETTINGS, TASK_UPDATE)) {
|
|
|
|
fs.readJson('config/site-settings.json')
|
|
|
|
fs.readJson('config/site-settings.json')
|
|
|
|
.then(obj => {
|
|
|
|
.then(obj => {
|
|
|
@ -89,7 +87,6 @@ router.post('/sync', (req, res) => {
|
|
|
|
message: "Nah. You can't do that. Talk to the admin, sport."
|
|
|
|
message: "Nah. You can't do that. Talk to the admin, sport."
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
router.get('/nav', function(req, res) {
|
|
|
|
router.get('/nav', function(req, res) {
|
|
|
@ -110,7 +107,6 @@ router.get('/nav', function(req, res) {
|
|
|
|
|
|
|
|
|
|
|
|
router.post('/nav-sync', (req, res) => {
|
|
|
|
router.post('/nav-sync', (req, res) => {
|
|
|
|
let payload = req.body;
|
|
|
|
let payload = req.body;
|
|
|
|
Models.User.findById(req.session.user.id).then(user => {
|
|
|
|
|
|
|
|
if (rightsManager.check(user.role, OBJECT_SETTINGS, TASK_UPDATE)) {
|
|
|
|
if (rightsManager.check(user.role, OBJECT_SETTINGS, TASK_UPDATE)) {
|
|
|
|
fs.readJson('config/site-settings.json')
|
|
|
|
fs.readJson('config/site-settings.json')
|
|
|
|
.then(obj => {
|
|
|
|
.then(obj => {
|
|
|
@ -133,7 +129,6 @@ router.post('/nav-sync', (req, res) => {
|
|
|
|
message: "Nah. You can't do that. Talk to the admin, sport."
|
|
|
|
message: "Nah. You can't do that. Talk to the admin, sport."
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
/***
|
|
|
|
/***
|
|
|
@ -145,7 +140,6 @@ router.post('/add-avatar', function(req, res) {
|
|
|
|
return res.json({
|
|
|
|
return res.json({
|
|
|
|
message: 'You need to be logged in, champ.'
|
|
|
|
message: 'You need to be logged in, champ.'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
Models.User.findById(req.session.user.id).then(user => {
|
|
|
|
|
|
|
|
if (rightsManager.check(user.role, OBJECT_POST, TASK_CREATE)) {
|
|
|
|
if (rightsManager.check(user.role, OBJECT_POST, TASK_CREATE)) {
|
|
|
|
avatar_upload(req, res, function(err) {
|
|
|
|
avatar_upload(req, res, function(err) {
|
|
|
|
if (err) {
|
|
|
|
if (err) {
|
|
|
@ -175,7 +169,6 @@ router.post('/add-avatar', function(req, res) {
|
|
|
|
message: "Nah. You can't do that. Talk to the admin, sport."
|
|
|
|
message: "Nah. You can't do that. Talk to the admin, sport."
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
/***
|
|
|
|
/***
|
|
|
|
UPLOAD FEATURE BACKGROUND
|
|
|
|
UPLOAD FEATURE BACKGROUND
|
|
|
@ -186,7 +179,6 @@ router.post('/add-feature-background', function(req, res) {
|
|
|
|
return res.json({
|
|
|
|
return res.json({
|
|
|
|
message: 'You need to be logged in, champ.'
|
|
|
|
message: 'You need to be logged in, champ.'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
Models.User.findById(req.session.user.id).then(user => {
|
|
|
|
|
|
|
|
if (rightsManager.check(user.role, OBJECT_POST, TASK_CREATE)) {
|
|
|
|
if (rightsManager.check(user.role, OBJECT_POST, TASK_CREATE)) {
|
|
|
|
background_upload(req, res, function(err) {
|
|
|
|
background_upload(req, res, function(err) {
|
|
|
|
if (err) {
|
|
|
|
if (err) {
|
|
|
@ -207,6 +199,5 @@ router.post('/add-feature-background', function(req, res) {
|
|
|
|
message: "Nah. You can't do that. Talk to the admin, sport."
|
|
|
|
message: "Nah. You can't do that. Talk to the admin, sport."
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
module.exports = router;
|
|
|
|
module.exports = router;
|
|
|
|