From c1c91de82ec1eaa3e837b2226c873ed1cba34914 Mon Sep 17 00:00:00 2001 From: jcianca <72471739+jcianca@users.noreply.github.com> Date: Thu, 23 May 2024 16:18:26 -0400 Subject: [PATCH] docs: update useAuth import in Supabase how-to (#10679) Update import { useAuth } from '@redwoodjs/auth' to 'src/auth' in the Supabase authentication how-to --- docs/docs/how-to/supabase-auth.md | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/docs/docs/how-to/supabase-auth.md b/docs/docs/how-to/supabase-auth.md index f5425b735daa..d2a3b29f7976 100644 --- a/docs/docs/how-to/supabase-auth.md +++ b/docs/docs/how-to/supabase-auth.md @@ -172,7 +172,7 @@ Let's import `useAuth` and destructure `client` from it in our component: ```jsx {2,5} title="web/src/pages/SignupPage/SignupPage.js" import { Form, TextField, PasswordField, Submit } from '@redwoodjs/forms' -import { useAuth } from '@redwoodjs/auth' +import { useAuth } from 'src/auth' const SignupPage = () => { const { client } = useAuth() @@ -199,7 +199,7 @@ And now we'll attempt to create a new user in the `onSubmit` function with [`cli ```jsx {8-16} title="web/src/pages/SignupPage/SignupPage.[js/tsx]" import { Form, TextField, PasswordField, Submit } from '@redwoodjs/forms' -import { useAuth } from '@redwoodjs/auth' +import { useAuth } from 'src/auth' const SignupPage = () => { const { client } = useAuth() @@ -236,7 +236,7 @@ Let's display errors to the user if there are any. To do this, we'll set up `Rea ```jsx {6,9,16,18,26} title="web/src/pages/SignupPage/SignupPage.js" import { Form, TextField, PasswordField, Submit } from '@redwoodjs/forms' -import { useAuth } from '@redwoodjs/auth' +import { useAuth } from 'src/auth' const SignupPage = () => { const { client } = useAuth() @@ -289,7 +289,7 @@ Let's import `routes` and `navigate` from [Redwood Router](../router.md#navigate ```jsx {3,16} title="web/src/pages/SignupPage/SignupPage.js" import { Form, TextField, PasswordField, Submit } from '@redwoodjs/forms' -import { useAuth } from '@redwoodjs/auth' +import { useAuth } from 'src/auth' import { routes, navigate } from '@redwoodjs/router' const SignupPage = () => { @@ -362,11 +362,11 @@ const SigninPage = () => { export default SigninPage ``` -Then we'll need to import `useAuth` from `@redwoodjs/auth` and destructure `logIn` so that we can use it in our `onSubmit` function: +Then we'll need to import `useAuth` from `src/auth` and destructure `logIn` so that we can use it in our `onSubmit` function: ```jsx {2,5} title="web/src/pages/SigninPage/SigninPage.js" import { Form, TextField, PasswordField, Submit } from '@redwoodjs/forms' -import { useAuth } from '@redwoodjs/auth' +import { useAuth } from 'src/auth' const SigninPage = () => { const { logIn } = useAuth() @@ -397,7 +397,7 @@ Now we'll add `logIn` to our `onSubmit` function. This time we'll be passing an ```jsx {10-15} title="web/src/pages/SigninPage/SigninPage.js" import { Form, TextField, PasswordField, Submit } from '@redwoodjs/forms' -import { useAuth } from '@redwoodjs/auth' +import { useAuth } from 'src/auth' const SigninPage = () => { const { logIn } = useAuth() @@ -435,7 +435,7 @@ In our `SigninPage`, import `navigate` and `routes` from [`@redwoodjs/router`](. ```jsx {10-16} title="web/src/pages/SigninPage/SigninPage.js" import { Form, TextField, PasswordField, Submit } from '@redwoodjs/forms' -import { useAuth } from '@redwoodjs/auth' +import { useAuth } from 'src/auth' import { navigate, routes } from '@redwoodjs/router' const SigninPage = () => { @@ -495,10 +495,10 @@ const SignoutBtn = () => { export default SignoutBtn ``` -Now let's import `useAuth` from `@redwoodjs/auth`. We'll destructure its `logOut` method and invoke it in `onClick`: +Now let's import `useAuth` from `src/auth`. We'll destructure its `logOut` method and invoke it in `onClick`: ```jsx {1,4,7} title="web/src/components/SignoutBtn/SignoutBtn.[js/tsx]" -import { useAuth } from '@redwoodjs/auth' +import { useAuth } from 'src/auth' const SignoutBtn = () => { const { logOut } = useAuth() @@ -515,7 +515,7 @@ export default SignoutBtn This works as is, but because the user may be in a restricted part of your app when they sign out, we should make sure to navigate them away from this page: ```jsx {2,8-9} title="web/src/components/SignoutBtn/SignoutBtn.[js/tsx]" -import { useAuth } from '@redwoodjs/auth' +import { useAuth } from 'src/auth' import { navigate, routes } from '@redwoodjs/router' const SignoutBtn = () => { @@ -552,7 +552,7 @@ We'll also import [`useAuth`](../authentication.md#api) since we'll need to subs ```jsx title="web/src/components/Navigation/Navigation.js" import { Link, routes } from '@redwoodjs/router' -import { useAuth } from '@redwoodjs/auth' +import { useAuth } from 'src/auth' const Navigation = () => { return @@ -565,7 +565,7 @@ Let's destructure `isAuthenticated` from the `useAuth` hook and use it in some c ```jsx {5,8-12} title="web/src/components/Navigation/Navigation.js" import { Link, routes } from '@redwoodjs/router' -import { useAuth } from '@redwoodjs/auth' +import { useAuth } from 'src/auth' const Navigation = () => { const { isAuthenticated } = useAuth() @@ -589,7 +589,7 @@ Now let's import our sign out button and add it, as well as sign in and sign up ```jsx {3,9-16} title="web/src/components/Navigation/Navigation.[js/tsx]" import { Link, routes } from '@redwoodjs/router' -import { useAuth } from '@redwoodjs/auth' +import { useAuth } from 'src/auth' import SignoutBtn from 'src/components/SignoutBtn/SignoutBtn' const Navigation = () => {