diff --git a/src/routes/(admin)/account_transfer/+page.server.ts b/src/routes/(admin)/account_transfer/+page.server.ts index 5063dff8f..17898aacf 100644 --- a/src/routes/(admin)/account_transfer/+page.server.ts +++ b/src/routes/(admin)/account_transfer/+page.server.ts @@ -16,6 +16,13 @@ import { Roles } from '$lib/types/user'; let accountTransferMessages: FloatingMessage[] = []; +/** + * Prepare data for the account transfer page by validating the current session, enforcing admin access, and constructing the transfer form. + * + * @param locals - SvelteKit locals providing `auth` for session validation and services used to fetch user data. + * @returns An object with `success: true`, `form`: the validated account transfer form with its `message` cleared, and `accountTransferMessages`: the module-level messages array related to account transfers. + * @throws Redirects to the login page when the session is missing or the authenticated user is not an admin. + */ export async function load({ locals }) { const session = await locals.auth.validate(); @@ -79,4 +86,4 @@ export const actions: Actions = { }; } }, -}; +}; \ No newline at end of file diff --git a/src/routes/workbooks/edit/[slug]/+page.server.ts b/src/routes/workbooks/edit/[slug]/+page.server.ts index 48280af43..4b6719299 100644 --- a/src/routes/workbooks/edit/[slug]/+page.server.ts +++ b/src/routes/workbooks/edit/[slug]/+page.server.ts @@ -14,6 +14,10 @@ import { workBookSchema } from '$lib/zod/schema'; import * as tasksCrud from '$lib/services/tasks'; import * as workBooksCrud from '$lib/services/workbooks'; +/** + * Loads workbook and author data, initializes a validation form and task lookups, and enforces edit permissions for the current user. + * + * @returns An object containing the initialized `form` (prefilled with the workbook), `loggedInAsAdmin` flag, the workbook with author data, `tasks`, and `tasksMapByIds`. If a logged-in user exists but is not authorized to edit the workbook, the returned object includes `status: FORBIDDEN` and a `message` describing the access restriction. */ export async function load({ locals, params }) { const loggedInUser = await getLoggedInUser(locals); const loggedInAsAdmin = isAdmin(loggedInUser?.role as Roles); @@ -97,4 +101,4 @@ export const actions = { redirect(TEMPORARY_REDIRECT, '/workbooks'); }, -}; +}; \ No newline at end of file