This commit is contained in:
Akif9748 2022-08-24 22:10:23 +03:00
parent 52ee616d64
commit d2e00d986f
5 changed files with 5 additions and 5 deletions

View file

@ -18,7 +18,7 @@ app.use(express.json());
app.use(async (req, res, next) => {
res.error = (type, error) => res.status(type).render("error", { type, error });
req.user = await UserModel.get(req.session.userid);
if (user.deleted) {
if (req.user?.deleted) {
req.session.destroy();
return res.error(403, "Your account has been deleted.");
}

View file

@ -259,4 +259,4 @@ img.logo {
height: 20px;
color: var(--col-15);
}
p {font-size: 15px;}
p {font-size: 17px;}

View file

@ -11,7 +11,7 @@ const { SecretModel, UserModel } = require("../../models")
*/
app.use(async (req, res, next) => {
res.error = (status, error) => res.status(status).json(error);
res.error = (status, error) => res.status(status).json({error});
res.complate = result => res.status(200).json(result);

View file

@ -8,7 +8,7 @@ const app = Router();
app.get("/:id", async (req, res) => {
const message = await MessageModel.get(id);
const message = await MessageModel.get(req.params.id);
if (!message || (message.deleted && req.user && !req.user.admin)) return res.error(404, `We don't have any thread with id ${id}.`);

View file

@ -32,7 +32,7 @@ app.get("/:id/messages/", async (req, res) => {
if (!messages.length) return res.error(404, "We don't have any messages in this thread.");
res.complate(messages.toObject({ virtuals: true }));
res.complate(messages.map(x => x.toObject({ virtuals: true })));
})