mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-06-01 00:13:20 -05:00
* Initial * CSS lint * Test CI * Add 1v1, 2v2, and 3v3 Tags (#1771) * Initial * CSS lint * Test CI * Rename step --------- Co-authored-by: xi <104683822+ximk@users.noreply.github.com>
25 lines
848 B
TypeScript
25 lines
848 B
TypeScript
import type { ActionFunction, LoaderFunctionArgs } from "@remix-run/node";
|
|
import { getUserId } from "~/features/auth/core/user.server";
|
|
import * as UserRepository from "~/features/user-page/UserRepository.server";
|
|
import { updatePatreonData } from "~/modules/patreon";
|
|
import { canAccessLohiEndpoint, canPerformAdminActions } from "~/permissions";
|
|
import { validate } from "~/utils/remix";
|
|
|
|
export const action: ActionFunction = async ({ request }) => {
|
|
const user = await getUserId(request);
|
|
|
|
if (!canPerformAdminActions(user) && !canAccessLohiEndpoint(request)) {
|
|
throw new Response("Not authorized", { status: 403 });
|
|
}
|
|
|
|
await updatePatreonData();
|
|
|
|
return null;
|
|
};
|
|
|
|
export const loader = ({ request }: LoaderFunctionArgs) => {
|
|
validate(canAccessLohiEndpoint(request), "Invalid token", 403);
|
|
|
|
return UserRepository.findAllPatrons();
|
|
};
|