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

Function authProviderFileContent

src/auth/authFiles/auth.$provider.ts:3–24  ·  view source on GitHub ↗
(config: WorkspaceConfiguration)

Source from the content-addressed store, hash-verified

1import { WorkspaceConfiguration } from "vscode";
2
3export const authProviderFileContent = (config: WorkspaceConfiguration) => {
4 const runtimeDependency = config.get("runtimeDependency") || "@remix-run/node";
5 return [
6 `import { redirect } from "${runtimeDependency}"`,
7 `import type { ActionFunctionArgs } from "${runtimeDependency}"`,
8 "import { authenticator } from '~/services/auth.server';",
9 'import type { AuthStrategy } from "~/services/auth.server";',
10 "",
11 "export const loader = () => redirect('/login');",
12 "",
13 "export const action = async ({ request, params }: ActionFunctionArgs) => {",
14 " // If the provider is not specified, redirect to the login page",
15 " if(!params.provider) return redirect('/login');",
16 "",
17 " const provider = params.provider as AuthStrategy;",
18 "",
19 " return await authenticator.authenticate(provider, request, {",
20 ' successRedirect: "/dashboard"',
21 " });",
22 "};",
23 ].join("\n");
24};

Callers 1

generateAuthFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected