sbr
04/01/2022, 4:48 AMwithoutAuthRequired() based on https://github.com/supabase-community/supabase-auth-helpers/blob/next/src/nextjs/README.md#server-side-rendering-ssr---withauthrequired to ensure that a login page is accessible only if the user hasn't logged in?Needle
04/01/2022, 4:48 AM/title command!
We have solved your problem?
Click the button below to archive it.sylar815
04/01/2022, 12:22 PMNeedle
04/01/2022, 12:22 PMsbr
04/04/2022, 7:04 PMwithAuthRequired then won't the page render only if the user if authenticated? Here is my usecase in a bit more detail-
- /login should be shown only if a user is not authenticated
- If a user is authenticated then /login should redirect to /home
- /home should be shown only if a user is authenticated
- If a user is not authenticated then /home should redirect to /loginsbr
04/04/2022, 7:05 PMwithAuthRequired. How can the first two points be implemented?sylar815
04/05/2022, 5:21 AM//something like this
const SignUp = () => {
const router = useRouter();
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
const { data } = await supabase.auth.signUp({
email,
password,
});
if (data) {
router.push('/dashboard');
} else {
router.push('/signin');
}
};sylar815
04/05/2022, 5:21 AM