basic search working

This commit is contained in:
Dominik Natter
2025-03-26 17:41:46 +01:00
parent a3104cfeb0
commit c5c9cc37af
13 changed files with 406 additions and 18 deletions

View File

@@ -8,7 +8,18 @@ export const Papers: CollectionConfig = {
plural: 'Diplomarbeiten',
},
access: {
create: ({ req: { user } }) => {
return Boolean(user?.type == "admin") // <-- Check if the user is authenticated
},
delete: ({ req: { user } }) => {
return Boolean(user?.type == "admin") // <-- Check if the user is authenticated
},
update: async ({ req: { user }, id, findByID }) => {
if (user?.type == "admin") return true; // Admins can update any paper
const paper = await findByID({ collection: 'papers', id });
return paper.authors.some(author => author.user === user.id); // Check if the user is an author
},
},
admin: {
useAsTitle: 'title',