UNPKG

screepsmod-auth

Version:

## This adds user/pass auth to the screeps private server

17 lines (15 loc) 591 B
module.exports = function (config) { config.cronjobs.authUpdates = [10, () => authUpdates(config)] } function authUpdates (config) { const { common: { storage: { db }}, auth: { screepsrc: { auth: { preventSpawning, registerCpu = 100} = {}} = {}}} = config let tgt = new Date(Date.now() - 15000) let newCpu = registerCpu; if (typeof newCpu === 'string') newCpu = parseInt(newCpu, 10); let $set = { cpu: newCpu, blocked: !!preventSpawning, authTouched: true } db.users.update({ $or: [{ registeredDate: { $gt: tgt }}, { authTouched: { $ne: true } }] }, { $set }) }