mirror of
https://github.com/Akif9748/akf-forum.git
synced 2024-12-22 23:59:08 +03:00
fix
This commit is contained in:
parent
52ee616d64
commit
d2e00d986f
5 changed files with 5 additions and 5 deletions
2
index.js
2
index.js
|
@ -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.");
|
||||
}
|
||||
|
|
|
@ -259,4 +259,4 @@ img.logo {
|
|||
height: 20px;
|
||||
color: var(--col-15);
|
||||
}
|
||||
p {font-size: 15px;}
|
||||
p {font-size: 17px;}
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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}.`);
|
||||
|
||||
|
|
|
@ -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 })));
|
||||
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in a new issue