mirror of
https://github.com/filecoin-project/slate.git
synced 2024-11-22 21:45:56 +03:00
server: fixes slate urls
This commit is contained in:
parent
3539a9a863
commit
d5e41daa4e
24
server.js
24
server.js
@ -64,7 +64,10 @@ app.prepare().then(async () => {
|
||||
return res.redirect("/404");
|
||||
}
|
||||
|
||||
const slates = await Data.getSlatesByUserId({ userId: creator.id, publicOnly: true });
|
||||
const slates = await Data.getSlatesByUserId({
|
||||
userId: creator.id,
|
||||
publicOnly: true,
|
||||
});
|
||||
|
||||
return app.render(req, res, "/profile", {
|
||||
viewer,
|
||||
@ -86,12 +89,27 @@ app.prepare().then(async () => {
|
||||
}
|
||||
|
||||
if (!slate.data.public) {
|
||||
// TODO(jim): Access denied page.
|
||||
return res.redirect("/403");
|
||||
}
|
||||
|
||||
const creator = await Data.getUserById({ id: slate.data.ownerId });
|
||||
|
||||
if (!creator) {
|
||||
return res.redirect("/404");
|
||||
}
|
||||
|
||||
if (creator.error) {
|
||||
return res.redirect("/404");
|
||||
}
|
||||
|
||||
if (req.params.username !== creator.username) {
|
||||
return res.redirect("/403");
|
||||
}
|
||||
|
||||
return app.render(req, res, "/slate", {
|
||||
slate: JSON.parse(JSON.stringify({ ...slate, ownername: req.params.username })),
|
||||
slate: JSON.parse(
|
||||
JSON.stringify({ ...slate, ownername: req.params.username })
|
||||
),
|
||||
});
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user