Files
myeasycms-v2/packages/features/admin/src/lib/server/admin-action.ts
giancarlo 2c7478abff Update language setting and versions in several packages
This commit includes an update of the language setting in the DocsPage and BlogPage functions in the marketing app to make it more dynamic. Additionally, the package versions of next, @makerkit/data-loader-supabase-nextjs, and various Next packages in the Supabase package have been updated.
2024-04-11 13:55:37 +08:00

23 lines
559 B
TypeScript

import { notFound } from 'next/navigation';
import { getSupabaseServerActionClient } from '@kit/supabase/server-actions-client';
import { isSuperAdmin } from './is-super-admin';
/**
* @name adminAction
* @description Wrap a server action to ensure the user is a super admin.
* @param fn
*/
export function adminAction<Args, Response>(fn: (params: Args) => Response) {
return async (params: Args) => {
const isAdmin = await isSuperAdmin(getSupabaseServerActionClient());
if (!isAdmin) {
notFound();
}
return fn(params);
};
}