diff --git a/docs/docs/01-getting-started/02-users.md b/docs/docs/01-getting-started/02-users.md index 005abe9e7..7c1aa2643 100644 --- a/docs/docs/01-getting-started/02-users.md +++ b/docs/docs/01-getting-started/02-users.md @@ -1,5 +1,5 @@ --- -sidebar_position: 2 +sidebar_position: 1 --- import Tabs from '@theme/Tabs'; diff --git a/docs/docs/01-getting-started/03-server-side.md b/docs/docs/01-getting-started/03-server-side.md index 2edbd7f1c..be435b803 100644 --- a/docs/docs/01-getting-started/03-server-side.md +++ b/docs/docs/01-getting-started/03-server-side.md @@ -1,5 +1,5 @@ --- -sidebar_position: 3 +sidebar_position: 1 --- # Server-Side App diff --git a/docs/docs/01-getting-started/04-going-into-production.md b/docs/docs/01-getting-started/04-going-into-production.md index 021807869..24ef3961f 100644 --- a/docs/docs/01-getting-started/04-going-into-production.md +++ b/docs/docs/01-getting-started/04-going-into-production.md @@ -1,5 +1,5 @@ --- -sidebar_position: 4 +sidebar_position: 1 --- # Going Into Production diff --git a/docs/docs/02-advanced-guides/01-customization/02-examples/01-signin.md b/docs/docs/02-advanced-guides/01-customization/02-examples/01-signin.md index b493010d9..e538428b8 100644 --- a/docs/docs/02-advanced-guides/01-customization/02-examples/01-signin.md +++ b/docs/docs/02-advanced-guides/01-customization/02-examples/01-signin.md @@ -17,7 +17,9 @@ export default function DefaultSignIn() { } ``` -`redirectUrl` is optional and defaults to the current page. +`redirectUrl` is the url the user will be redirected to after successful signing in. It is optional and defaults to the current page. + +You can also use `useUser` at the beginning of the sign in page to check if wether the user is already signed in and redirect them to some other page if they are. ## Custom OAuth Sign In @@ -41,3 +43,39 @@ export default function CustomOAuthSignIn() { ## Custom Credential Sign In ```tsx +'use client'; +import { useStackApp, validateEmail } from "@stackframe/stack"; +import { useState } from "react"; + +export default function CustomCredentialSignIn() { + const [email, setEmail] = useState(''); + const [password, setPassword] = useState(''); + const [error, setError] = useState(''); + const app = useStackApp(); + + const onSubmit = async () => { + if (!validateEmail(email)) { + setError('Please enter a valid email'); + return; + } + if (!password) { + setError('Please enter your password'); + return; + } + const errorCode = await app.signInWithCredential({ email, password, redirectUrl: app.urls.userHome }); + // It is better to handle each error code separately, but for simplicity in this example, we will just show the error code directly + if (errorCode) { + setError(errorCode); + } + }; + + return ( +