blob: cf5be141161c46b167ec08aefc4e83b5a870a4be (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
import type { ActionFunctionArgs, LoaderFunctionArgs } from "@remix-run/node";
import { Form } from "@remix-run/react";
import { authenticator } from "../services/auth.server";
export async function loader({ request }: LoaderFunctionArgs) {
return await authenticator.isAuthenticated(request, {
successRedirect: "/dashboard",
});
}
export async function action({ request }: ActionFunctionArgs) {
return await authenticator.authenticate("default", request, {
successRedirect: "/dashboard",
failureRedirect: "/login",
});
}
export default function Login() {
return (
<Form method="post">
<input type="username" name="username" required />
<input
type="password"
name="password"
autoComplete="current-password"
required
/>
<button>Log In</button>
</Form>
);
}
|