src/services/auth.service.ts. The service uses the Supabase Auth client for session management and the customer_profiles table for extended profile data.
Key behaviors
signUpauto-creates a profile — immediately after Supabase Auth creates the user,createCustomerProfileis called with anupsertto populatecustomer_profiles. Profile creation errors are swallowed so they never block signup.- All date fields are ISO 8601 strings.
resetPasswordandsignUpboth usewindow.location.originas the redirect base, so they require a browser context.
signUp()
customer_profiles row in one call.
User’s email address.
Password (min 6 characters enforced by Supabase).
Optional display name stored in
customer_profiles.full_name.Phone number stored in both
phone and whatsapp columns initially.Optional AI personalisation preferences.
Optional IA context object for the AI concierge.
Supabase Auth response containing
user and session.signIn()
signInWithPassword. Throws the Supabase error on failure.
signOut()
resetPassword()
resetPasswordForEmail. Redirects to {origin}/login after the user clicks the link.
Email address to send the reset link to.
getCurrentUser()
supabase.auth.getUser(). Returns null if no authenticated session exists.
getCustomerProfile()
customer_profiles row for a user. Uses maybeSingle() so it returns null instead of an error when the profile doesn’t exist yet.
The
auth.users.id UUID.The extended profile, or
null if not found.createCustomerProfile()
customer_profiles. Called automatically by signUp but can also be called manually when a user profile needs to be force-created. Errors are not thrown — they are logged to console.error.
updateProfile()
customer_profiles. Throws on Supabase error.
The
auth.users.id UUID.Partial profile fields to update.
Usage with AuthContext
In practice, components use theuseAuth() hook which reads from AuthContext rather than calling these service functions directly. The context provides user, profile, loading, and signIn, signUp, signOut wrappers.
