12 lines
440 B
TypeScript
12 lines
440 B
TypeScript
import type { H3Event, EventHandlerRequest } from "h3";
|
|
import { IStory } from "~/models/stories";
|
|
export function canDelete(event: H3Event<EventHandlerRequest>, story: IStory) {
|
|
return (
|
|
event.context.currentUser?.profile.isAdmin ||
|
|
story.author._id === event.context.currentUser?._id
|
|
);
|
|
}
|
|
export function canModify(event: H3Event<EventHandlerRequest>, story: IStory) {
|
|
return event.context.currentUser?._id === story.author._id;
|
|
}
|