Skip to content

Commit

Permalink
Merge pull request #1241 from syntaxfm/issue-1236
Browse files Browse the repository at this point in the history
disallow viewing of future shows if not an admin
  • Loading branch information
wesbos authored Oct 23, 2023
2 parents f7b9076 + 33ef28a commit 484686f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/routes/(site)/+error.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<script>
import { page } from '$app/stores';
</script>

<div class="error">
<h1>Oopsie-daisy</h1>
<p>Something went wrong. Don't worry, we use Sentry!</p>
{#if $page.error.message}
<p>{$page.error.message}</p>
{:else}
<p>Something went wrong. Don't worry, we use Sentry!</p>
{/if}
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { cache } from '$lib/cache/cache';
import { transcript_with_utterances } from '$server/ai/queries.js';
import type { Prisma, Show } from '@prisma/client';
import type { PageServerLoad } from './$types';
import { error } from '@sveltejs/kit';

export const load: PageServerLoad = async function ({ setHeaders, params, locals, url }) {
const { show_number } = params;
Expand Down Expand Up @@ -48,6 +49,14 @@ export const load: PageServerLoad = async function ({ setHeaders, params, locals
}
}

// Check if this is a future show
const now = new Date();
const show_date = new Date(show_raw?.date || '');
const is_admin = locals?.user?.roles?.includes('admin');
if (show_date > now && !is_admin) {
throw error(401, `That is a show, but it's in the future! \n\nCome back ${show_date}`);
}

const body_excerpt = await unified()
.use(remarkParse)
.use(remarkGfm)
Expand Down

1 comment on commit 484686f

@vercel
Copy link

@vercel vercel bot commented on 484686f Oct 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

syntax-website – ./

syntax-website-git-main-syntax.vercel.app
www.syntax.fm
syntax-website-syntax.vercel.app
syntax.fm
beta.syntax.fm

Please sign in to comment.