fix: allow more variables on view

This commit is contained in:
diced 2023-01-26 15:58:06 -08:00
parent 55bd72aef8
commit 9f534e18c8
No known key found for this signature in database
GPG key ID: 370BD1BA142842D1

View file

@ -173,29 +173,16 @@ export const getServerSideProps: GetServerSideProps = async (context) => {
where: {
OR: [{ name: id }, { invisible: { invis: id } }],
},
select: {
mimetype: true,
id: true,
name: true,
invisible: true,
userId: true,
createdAt: true,
password: true,
embed: true,
},
});
if (!file) return { notFound: true };
const user = await prisma.user.findFirst({
select: {
username: true,
id: true,
embed: true,
},
where: {
id: file.userId,
},
});
delete user.password;
delete user.totpSecret;
// @ts-ignore workaround because next wont allow date
file.createdAt = file.createdAt.toString();
@ -227,6 +214,8 @@ export const getServerSideProps: GetServerSideProps = async (context) => {
const data = await datasource.get(file.name);
if (!data) return { notFound: true };
delete file.password;
return {
props: {
file,
@ -234,6 +223,7 @@ export const getServerSideProps: GetServerSideProps = async (context) => {
},
};
}
const pass = file.password ? true : false;
delete file.password;
return {