0
0
Supabasecloud~10 mins

Email/password authentication in Supabase - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Email/password authentication
User enters email & password
Send credentials to Supabase Auth
Supabase checks credentials
Create session
User logged in
User inputs email and password, Supabase verifies them, then either logs the user in or shows an error.
Execution Sample
Supabase
const { data, error } = await supabase.auth.signInWithPassword({
  email: 'user@example.com',
  password: 'password123'
})
This code sends the email and password to Supabase to authenticate the user.
Process Table
StepActionInputSupabase ResponseResult
1User inputs email and passwordemail='user@example.com', password='password123'N/ACredentials ready to send
2Send credentials to SupabaseCredentials sentChecking credentialsWaiting for response
3Supabase verifies credentialsEmail and passwordValid user foundSession created
4Return session dataSession tokenSession token returnedUser logged in
5If credentials invalidWrong email or passwordError returnedShow error message
💡 Execution stops after Supabase returns session or error response.
Status Tracker
VariableStartAfter Step 1After Step 2After Step 3After Step 4
emailundefined'user@example.com''user@example.com''user@example.com''user@example.com'
passwordundefined'password123''password123''password123''password123'
dataundefinedundefinedundefined{ session: {...} }{ session: {...} }
errorundefinedundefinedundefinednullnull
Key Moments - 3 Insights
Why do we wait after sending credentials to Supabase?
Because Supabase needs time to check the credentials and respond, as shown in step 2 and 3 of the execution_table.
What happens if the email or password is wrong?
Supabase returns an error instead of a session, as shown in step 5 of the execution_table.
Why do we store the session token after login?
The session token keeps the user logged in for future requests, shown in step 4 where session data is returned.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the Supabase response at step 3?
ACredentials sent
BValid user found
CError returned
DSession token returned
💡 Hint
Check the 'Supabase Response' column in row for step 3.
At which step does the user get logged in?
AStep 5
BStep 2
CStep 4
DStep 1
💡 Hint
Look at the 'Result' column for when the user is logged in.
If the password is incorrect, which step shows the error?
AStep 5
BStep 3
CStep 4
DStep 2
💡 Hint
See the 'Result' column where error message is shown.
Concept Snapshot
Email/password authentication with Supabase:
- User inputs email and password
- Credentials sent to Supabase Auth
- Supabase verifies credentials
- If valid, session created and user logged in
- If invalid, error returned
Use supabase.auth.signInWithPassword({email, password})
Full Transcript
This visual execution shows how email and password authentication works with Supabase. First, the user enters their email and password. These credentials are sent to Supabase's authentication service. Supabase checks if the credentials match a registered user. If they do, Supabase creates a session and returns a session token, logging the user in. If the credentials are wrong, Supabase returns an error message. Variables like email, password, data, and error change as the process moves forward. Key moments include waiting for Supabase's response, handling errors, and storing the session token. The quiz questions help reinforce understanding by referencing specific steps in the execution table.