arch-atlas

Register Notifier

auth/register · Notifier<RegisterState>

domain

Overview

Posts a new customer to /auth/customer/emailpass-verified/register but deliberately does NOT persist a session — the user is logged in only after they verify the OTP emailed by the backend (see the OTP step in the onboarding-register wizard).

User Flow

  1. RegisterStepPage submits → register(email, password).
  2. AuthApiService.register POSTs the credentials and gets back a RegisterResponse.
  3. On success state.isVerified flips to true (semantic: 'request accepted, awaiting OTP').
  4. Wizard advances to OtpStepPage; the actual session is saved by AuthStorageService.saveSessionOtp after /auth/customer/emailpass-verified/verify.

Cases & Edge Cases

  • Backend returns 200 with {type: 'unauthorized'} — surfaced as an Exception (Medusa-style soft failure).
  • Email already exists → backend returns a structured error; message is hoisted unchanged into state.error.
  • Session is intentionally not saved here — calling save before OTP verification would log the user into an unverified account.

Code References

  • lib/src/features/shared/auth/register/register_notifier.dart:17 // register()
  • lib/src/features/shared/auth/register/register_request.dart
  • lib/src/features/shared/auth/register/register_response.dart
  • lib/src/core/services/auth_service.dart:193 // AuthApiService.register

API Calls

  • POST/auth/customer/emailpass-verified/registerno status

    Create a customer account; backend emails an OTP and does NOT issue a session yet.

    Request
    { email: string, password: string }
    Response
    { success: true }
    Errors
    • ·200 with { type: 'unauthorized', message } — Medusa-style soft failure surfaced as Exception
    lib/src/features/shared/onboarding_register/presentation/pages/register_step_page.dart

    auth: none. Session is intentionally NOT saved here — the user is authenticated only after the OTP verify call.

  • POST/auth/customer/emailpass-verified/verifyno status

    Verify the emailed OTP and finally issue the customer session token.

    Request
    { email: string, otp: string }
    Response
    { token: string }
    lib/src/features/shared/onboarding_register/presentation/pages/otp_step_page.dart

    auth: none. The returned token is persisted via AuthStorageService.saveSessionOtp.

Notes

isVerified in RegisterState is misleadingly named — it means 'register call succeeded', not 'email verified'. The actual verification happens in the OTP step.