fix(client): 🐛 do not allow private resumes to be viewable or downloadable through the link

This commit is contained in:
Amruth Pillai
2023-07-12 15:59:22 +02:00
parent 5ef4bfcb6b
commit 1c2d796c50
121 changed files with 3193 additions and 2068 deletions

View File

@ -42,14 +42,10 @@ const Build: NextPage<Props> = ({ username, slug }) => {
`resume/${username}/${slug}`,
() => fetchResumeByIdentifier({ username, slug }),
{
cacheTime: 0,
refetchOnMount: false,
refetchOnReconnect: false,
refetchOnWindowFocus: false,
onSuccess: (resume) => {
dispatch(setResume(resume));
},
}
},
);
useEffect(() => {
@ -62,7 +58,7 @@ const Build: NextPage<Props> = ({ username, slug }) => {
<div className={styles.container}>
<Head>
<title>
{resume.name} | {t<string>('common.title')}
{resume.name} | {t('common.title')}
</title>
</Head>

View File

@ -57,6 +57,16 @@ const Preview: NextPage<Props> = ({ username, slug, resume: initialData }) => {
useEffect(() => {
if (initialData && !isEmpty(initialData)) {
const errorObj = JSON.parse(JSON.stringify(initialData));
const statusCode: number | null = get(errorObj, 'statusCode', null);
if (statusCode === 404) {
toast.error('The resume you were looking for does not exist, or maybe it never did?');
router.push('/');
return;
}
dispatch(setResume(initialData));
}
}, [dispatch, initialData]);
@ -73,10 +83,6 @@ const Preview: NextPage<Props> = ({ username, slug, resume: initialData }) => {
useQuery<Resume>(`resume/${username}/${slug}`, () => fetchResumeByIdentifier({ username, slug }), {
initialData,
retry: false,
refetchOnMount: false,
refetchOnReconnect: false,
refetchOnWindowFocus: false,
onSuccess: (data) => {
dispatch(setResume(data));
},