Skip to content

Commit

Permalink
chore: restrict CV access to session user and company users
Browse files Browse the repository at this point in the history
Co-authored-by: Alexander Biraben-Renard <[email protected]>
  • Loading branch information
matalex412 and alexanderbira committed Aug 21, 2024
1 parent e4beda8 commit 43d54f4
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions app/students/[shortcode]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,20 @@ const StudentProfilePage = async ({ params }: { params: { shortcode: string } })
)}

{studentProfile.cv && (
<Flex align="center" gap="2" asChild>
<Link href={`/api/uploads/${studentProfile.cv}`} target="_blank" underline="none">
<BsFileEarmarkText title="download cv" color="black" />
<Text>{studentProfile.user.name?.split(",").reverse()[0].trim()}&apos;s CV</Text>
</Link>
</Flex>
<RestrictedArea
showMessage={false}
allowedRoles={["COMPANY", "STUDENT"]}
additionalCheck={async session =>
session.user.role === "COMPANY" || session.user.id === studentProfile.userId
}
>
<Flex align="center" gap="2" asChild>
<Link href={`/api/uploads/${studentProfile.cv}`} target="_blank" underline="none">
<BsFileEarmarkText title="download cv" color="var(--gray-12)" />
<Text>{studentProfile.user.name?.split(",").reverse()[0].trim()}&apos;s CV</Text>
</Link>
</Flex>
</RestrictedArea>
)}
<Flex align="center" gap="2">
<BsEnvelope />
Expand Down

0 comments on commit 43d54f4

Please sign in to comment.