Skip to content

Commit 79aa354

Browse files
authored
add initiate login endpoint to /login (#7)
1 parent 54cf85d commit 79aa354

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

app/components/sign-in-button.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useRootLoaderData } from '~/root';
44

55
export default function SignInButton({ large }: { large?: boolean }) {
66
const rootLoaderData = useRootLoaderData();
7-
const { user, signInUrl } = rootLoaderData || {};
7+
const { user } = rootLoaderData || {};
88

99
if (user) {
1010
return (
@@ -20,7 +20,7 @@ export default function SignInButton({ large }: { large?: boolean }) {
2020

2121
return (
2222
<Button asChild size={large ? '3' : '2'}>
23-
<a href={signInUrl}>Sign In{large && ' with AuthKit'}</a>
23+
<a href="/login">Sign In{large && ' with AuthKit'}</a>
2424
</Button>
2525
);
2626
}

app/root.tsx

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,11 @@ import { Links, Link, Meta, Outlet, Scripts, ScrollRestoration, useRouteLoaderDa
88
import Footer from './components/footer';
99
import SignInButton from './components/sign-in-button';
1010

11-
import { getSignInUrl, signOut, authkitLoader } from '@workos-inc/authkit-react-router';
11+
import { signOut, authkitLoader } from '@workos-inc/authkit-react-router';
1212

1313
export const links: LinksFunction = () => [];
1414

15-
export const loader = (args: LoaderFunctionArgs) =>
16-
authkitLoader(
17-
args,
18-
async () => {
19-
return {
20-
signInUrl: await getSignInUrl(),
21-
};
22-
},
23-
{ debug: true },
24-
);
15+
export const loader = (args: LoaderFunctionArgs) => authkitLoader(args, { debug: true });
2516

2617
export function useRootLoaderData() {
2718
return useRouteLoaderData<typeof loader>('root');

app/routes/login.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { getSignInUrl } from '@workos-inc/authkit-react-router';
2+
import { redirect } from 'react-router';
3+
4+
export const loader = async () => {
5+
const signInUrl = await getSignInUrl();
6+
7+
return redirect(signInUrl);
8+
};

0 commit comments

Comments
 (0)