Respect CONFIG_ENABLED_APPS in .env

This commit is contained in:
Bruno Bernardino
2024-05-01 09:21:30 +01:00
parent 635ca90de0
commit 6ee0a56f0c
8 changed files with 64 additions and 42 deletions

View File

@@ -1,6 +1,7 @@
import { Handlers, PageProps } from 'fresh/server.ts';
import { FreshContextState, NewsFeedArticle } from '/lib/types.ts';
import { isAppEnabled } from '/lib/config.ts';
import { getNewsArticles } from '/lib/data/news.ts';
import Articles from '/islands/news/Articles.tsx';
@@ -14,6 +15,10 @@ export const handler: Handlers<Data, FreshContextState> = {
return new Response('Redirect', { status: 303, headers: { 'Location': `/login` } });
}
if (!isAppEnabled('news')) {
return new Response('Redirect', { status: 303, headers: { 'Location': `/dashboard` } });
}
const userArticles = await getNewsArticles(context.state.user.id);
return await context.render({ userArticles });