mirror of
https://github.com/Akif9748/akf-forum.git
synced 2024-11-01 03:25:04 +03:00
15 lines
No EOL
395 B
JavaScript
15 lines
No EOL
395 B
JavaScript
const { TimeoutModel } = require("../models");
|
|
module.exports = async (req, res, next) => {
|
|
if (!req.user || req.user.admin) return next();
|
|
|
|
const timeout = await TimeoutModel.findOne({ id: req.user.id }) || new TimeoutModel({ until: Date.now() - 1000, id: req.user.id });
|
|
|
|
req.timeout = timeout;
|
|
|
|
if (timeout.until > Date.now())
|
|
req.ratelimit = true;
|
|
|
|
|
|
next();
|
|
|
|
}
|