From 389b1948bb16d6f7cc4735a8ba09b0692e473cb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Mon, 26 Sep 2022 18:29:17 +0200 Subject: [PATCH] Use `ActionArgs` instead of `ActionFunction` (#16) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: use `ActionArgs` instead of `ActionFunction` * Update README.md * Apply suggestions from code review * Update README.md Co-authored-by: Sergio Xalambrí --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 66b4ef7..b86b8be 100644 --- a/README.md +++ b/README.md @@ -64,10 +64,10 @@ authenticator.use( ); ``` -In order to authenticate a user, you can use the following inside of an ActionFunction: +In order to authenticate a user, you can use the following inside of an `action` function: ```ts -export const action: ActionFunction = async ({ request, context }) => { +export async function action({ context, request }: ActionArgs) { return await authenticator.authenticate("form", request, { successRedirect: "/", failureRedirect: "/login", @@ -81,7 +81,7 @@ export const action: ActionFunction = async ({ request, context }) => { Because you may want to do validations or read valeus from the FormData before calling `authenticate`, the FormStrategy allows you to pass a FormData object as part of the optional context. ```ts -export const action: ActionFunction = async ({ request, context }) => { +export async function action({ context, request }: ActionArgs) { let formData = await request.formData(); return await authenticator.authenticate("form", request, { // use formData here