bunch of changes to help with development (no nginx) and new installs

merge-requests/208/head
fatchan 5 years ago
parent 74e267cc10
commit 3cc9c68e96
  1. 1
      .gitignore
  2. 3
      db/accounts.js
  3. 16
      db/files.js
  4. 2
      db/modlogs.js
  5. 2
      db/news.js
  6. 2
      db/ratelimits.js
  7. 2
      db/stats.js
  8. 11
      gulpfile.js
  9. 12
      helpers/sessionrefresh.js

1
.gitignore vendored

@ -2,5 +2,6 @@ node_modules/
backup.sh backup.sh
configs/*.json configs/*.json
static/* static/*
gulp/res/js/socket.io.js
gulp/dist/ gulp/dist/
tmp/ tmp/

@ -7,6 +7,8 @@ const Mongo = require(__dirname+'/db.js')
module.exports = { module.exports = {
db,
count: (usernames) => { count: (usernames) => {
return db.countDocuments({ return db.countDocuments({
'_id': { '_id': {
@ -22,7 +24,6 @@ module.exports = {
insertOne: async (username, password, authLevel) => { insertOne: async (username, password, authLevel) => {
// hash the password // hash the password
const passwordHash = await bcrypt.hash(password, 12); const passwordHash = await bcrypt.hash(password, 12);
//add to db //add to db
return db.insertOne({ return db.insertOne({
'_id': username, '_id': username,

@ -56,10 +56,18 @@ module.exports = {
} }
]).toArray().then(res => { ]).toArray().then(res => {
const stats = res[0]; const stats = res[0];
return { if (stats) {
count: stats.count, return {
totalSize: stats.size, count: stats.count,
totalSizeString: formatSize(stats.size) totalSize: stats.size,
totalSizeString: formatSize(stats.size)
}
} else {
return {
count: 0,
totalSize: 0,
totalSizeString: '0B'
}
} }
}); });
}, },

@ -5,6 +5,8 @@ const Mongo = require(__dirname+'/db.js')
module.exports = { module.exports = {
db,
getDates: (board) => { getDates: (board) => {
return db.aggregate([ return db.aggregate([
{ {

@ -6,6 +6,8 @@ const Mongo = require(__dirname+'/db.js')
module.exports = { module.exports = {
db,
find: () => { find: () => {
return db.find({}).sort({ return db.find({}).sort({
'_id': -1 '_id': -1

@ -31,7 +31,7 @@ module.exports = {
}, },
deleteAll: () => { deleteAll: () => {
return ratelimit.deleteMany({}); return db.deleteMany({});
}, },
} }

@ -6,6 +6,8 @@ const Mongo = require(__dirname+'/db.js')
module.exports = { module.exports = {
db,
updateOne: (board, ip, thread) => { updateOne: (board, ip, thread) => {
return db.updateOne({ return db.updateOne({
'board': board, 'board': board,

@ -34,14 +34,7 @@ async function wipe() {
const Mongo = require(__dirname+'/db/db.js'); const Mongo = require(__dirname+'/db/db.js');
await Mongo.connect(); await Mongo.connect();
const { Boards, Posts, Captchas, Ratelimits, const { Boards, Posts, Captchas, Ratelimits,
Accounts, Files, Stats, Modlogs, Bans } = require(__dirname+'/db/') Accounts, Files, Stats, Modlogs, Bans } = require(__dirname+'/db/');
, Posts = require(__dirname+'/db/posts.js')
, Bans = require(__dirname+'/db/bans.js')
, Captchas = require(__dirname+'/db/captchas.js')
, Ratelimits = require(__dirname+'/db/ratelimits.js')
, Accounts = require(__dirname+'/db/accounts.js')
, Files = require(__dirname+'/db/files.js')
, Stats = require(__dirname+'/db/stats.js');
//wipe db shit //wipe db shit
await Promise.all([ await Promise.all([
@ -157,7 +150,7 @@ function scripts() {
.pipe(gulp.dest(paths.scripts.dest)); .pipe(gulp.dest(paths.scripts.dest));
} }
const build = gulp.parallel(css, scripts, images, deletehtml, custompages); const build = gulp.parallel(css, scripts, images, gulp.series(deletehtml, custompages));
const reset = gulp.series(wipe, build) const reset = gulp.series(wipe, build)
const html = gulp.series(deletehtml, custompages) const html = gulp.series(deletehtml, custompages)

@ -6,10 +6,14 @@ module.exports = async (req, res, next) => {
if (req.session && req.session.authenticated === true) { if (req.session && req.session.authenticated === true) {
// keeping session updated incase user updated on global manage // keeping session updated incase user updated on global manage
const account = await Accounts.findOne(req.session.user.username); const account = await Accounts.findOne(req.session.user.username);
req.session.user = { if (!account) {
'username': account._id, req.session.destroy();
'authLevel': account.authLevel } else {
}; req.session.user = {
'username': account._id,
'authLevel': account.authLevel
};
}
} }
next(); next();
} }

Loading…
Cancel
Save