MCPcopy Create free account
hub / github.com/code-forge-io/Remix-Forge / loginFileContent

Function loginFileContent

src/auth/authFiles/login.ts:3–34  ·  view source on GitHub ↗
(options: AUTH_STRATEGY_OPTION[])

Source from the content-addressed store, hash-verified

1import { AUTH_STRATEGY_OPTION } from "../config/options";
2
3export const loginFileContent = (options: AUTH_STRATEGY_OPTION[]) => {
4 const buttons = options
5 .map(
6 (option) =>
7 ` <SocialButton provider={AuthStrategies.${option.key.toUpperCase()}} label="Login with ${option.key}" />`
8 )
9 .join("\n");
10 return [
11 'import { Form } from "@remix-run/react"',
12 'import { AuthStrategies } from "~/services/auth_strategies";',
13 'import type { AuthStrategy } from "~/services/auth.server";',
14 "",
15 "interface SocialButtonProps {",
16 " provider: AuthStrategy,",
17 " label: string",
18 "}",
19 "",
20 "const SocialButton = ({ provider, label }: SocialButtonProps) => (",
21 ' <Form action={`/auth/${provider}`} method="post">',
22 " <button>{label}</button>",
23 " </Form>",
24 ");",
25 "",
26 "export default function LoginRoute() {",
27 " return (",
28 " <>",
29 buttons,
30 " </>",
31 " );",
32 "}",
33 ].join("\n");
34};

Callers 1

generateAuthFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected