Sign Up and Sign In
Creating an account, confirming the email code, signing in with email, Google or Apple, how tokens are stored and refreshed, and signing out.
All authentication screens live in the (auth) route group. One sign-up form serves both tenants and agents; the account type chosen there becomes the user's role, and the role decides which navigator opens after sign-in.
Where it lives
| Screen | Route | File | Who sees it |
|---|---|---|---|
| Auth stack | none | app/(auth)/_layout.tsx | Signed-out users |
| Sign up | /signup | app/(auth)/signup.tsx | Signed-out users |
| Confirm your Email | /confirm-email | app/(auth)/confirm-email.tsx | New accounts, and password reset |
| Sign in | /signin | app/(auth)/signin.tsx | Signed-out users, and anyone whose session expired |
| Check mail | /check-mail | app/(auth)/check-mail.tsx | Nobody (placeholder) |
| Verify email | /verify-email | app/(auth)/verify-email.tsx | Nobody (placeholder) |
| Google callback | /google-callback | app/(auth)/google-callback.tsx | Nobody (placeholder) |
Supporting code: services/auth/auth-thunk.ts (API calls), services/auth/auth-slice.ts (Redux auth), services/auth/google-signin.ts, services/auth/apple-signin.ts, services/auth/auth-session.ts, store/config.ts (token refresh), hooks/storage.ts.
Three placeholder screens
check-mail, verify-email and google-callback each render only their own name as text. Nothing navigates to them. The thunks verifyEmail (GET /api/v1/auth/verify-email), initGoogleOAuth (GET /api/v1/auth/google) and googleCallback (GET /api/v1/auth/google/callback) exist in auth-thunk.ts but no screen dispatches them; they are leftovers from the web link flow.
Before you start
- Network access. Every step calls the API.
- Google sign-in appears only on iOS builds configured with an iOS OAuth client id. It is switched off on Android in code.
- Apple sign-in appears only on iOS, and only when the OS reports it as available.
Flow
Sign up with email
- The user arrives from "Get Started" or from the "Sign up" link on the sign-in screen. The header reads "Welcome to" / "Home Link Hub".
- Under "I want to", the user picks an account type. "Find a home" (default) sends
role: "TENANT"; "List properties" sendsrole: "AGENT". Landlord, lawyer and developer accounts cannot be created from the app. - The user fills in three fields:
| Field | Rule in the app | Rule on the server |
|---|---|---|
| Full Name | Required. Split on the first space into first name and the rest as last name. | First and last name each 2 to 50 characters, both required |
| Email Address | Required. Trimmed. | Valid email, lowercased |
| Password | Required. No length check in the app. | 8 to 128 characters |
- Tapping "Continue" with any field empty shows the alert "Error" / "Please fill in all fields.". A name that yields no first name shows "Please provide a first and last name.".
- Otherwise the app fires
POST /api/v1/auth/signupwithfirstName,lastName,email,password,roleandisMobile: true. The button reads "Creating account..." while Reduxauth.loadingis true. - On success a toast shows "Account Created!" / "A verification code has been sent to your email." and the app pushes
/confirm-emailwith paramsemail(lowercased) andpurposeset tosignup. Nothing is stored yet; the user is not signed in. - On failure the alert "Signup Failed" shows the server's message (for example that the email is already registered), or "Signup failed. Please try again.".
Single-word names and short passwords fail at the server
The app accepts a one-word full name and any password length, but the API rejects a last name shorter than 2 characters and a password shorter than 8. The user sees the server's validation message in the "Signup Failed" alert.
The footer links "Terms of Use" and "Privacy Policy" open the website pages in the browser. "Log in" pushes /signin.
Confirm the email code
- The screen titled "Confirm your Email" shows four single-digit boxes. Typing a digit moves focus to the next box; backspace on an empty box moves back.
- "Confirm" with fewer than four digits shows "Error" / "Please enter the complete 4-digit code.".
- With
purposeset tosignupthe app firesPOST /api/v1/auth/verify-email-otpwithemailandcode. The button reads "Verifying...". - Success shows the toast "Email Verified" / "You can now sign in." and replaces the route with
/signin. The user must now sign in; verification does not create a session. - Failure shows "Verification Failed" with the server message or "Invalid or expired code. Please try again.". If the email param is missing: "Missing email. Please sign up again.".
- Resend: the link reads "Resend Code in 01:00" and counts down. At zero it becomes "Resend Code". Tapping it fires
POST /api/v1/auth/resend-verificationwithemailandisMobile: true, shows "Success" / "A new verification code has been sent to your email.", clears the boxes and restarts the 60 second timer. Failure shows "Error" with the server message or "Failed to resend code. Please try again.".
The backend generates a 4-digit code that is valid for 15 minutes. The same screen is reused by Password reset, where "Confirm" does not call the API.
Sign in with email
- The screen is titled "Welcome Back!". Fields: "Email Address" and "Password" (with a show or hide eye icon).
- "Remember me" is a checkbox, off by default. "Forgot Password?" pushes
/password-reset. - "Sign in" with either field blank shows "Error" / "Please enter both email and password.".
- Otherwise the app fires
POST /api/v1/auth/signinwithemail(trimmed) andpassword. The button reads "Signing in...". - On success the thunk stores:
session:ACCESS_TOKEN(access token)local:REFRESH_TOKEN(refresh token)local:USER(the user object)- Redux
auth.user
- The screen then writes the checkbox value to
local:REMEMBER_MEand replaces the route withpostAuthRouteForRole(role):/tenantfor tenants,/agent-onboardingfor agents,/(tabs)for landlords, lawyers and developers. - If the server rejects with
errorData.codeequal toEMAIL_NOT_VERIFIED, the app immediately firesPOST /api/v1/auth/resend-verification, shows the info toast "Verify your email" / "We've sent a verification code to your email.", and pushes/confirm-emailwithpurposeset tosignup. If that resend fails, the alert "Verification Required" shows the server message or "Your email isn't verified and we couldn't send a code. Please try again.". - Any other failure shows "Sign In Failed" with the server message or "Could not sign in. Please verify your credentials.".
Continue with Google
- The "Google" button shows under "or continue with" on both sign-in and sign-up when Google sign-in is available (iOS only, see above).
- Tapping it opens Google's native account sheet. The app takes the returned ID token and fires
POST /api/v1/auth/google/nativewithidToken. From the sign-up screen it also sendsrole(the selected account type), which applies only if this creates a new account. - Success stores the same three AsyncStorage keys as email sign-in and routes by the role the server returned.
- Cancelling the sheet does nothing. Other failures show "Google Sign In Error" with the error message or "An error occurred". Missing Play services shows "Error" / "Play services not available or outdated".
Continue with Apple
- Apple's own "Continue with Apple" button (black in light mode, white in dark mode) shows on iOS when available.
- The system sheet asks for name and email. The app sends
POST /api/v1/auth/apple/nativewithidentityToken,authorizationCode,firstName,lastName, and from the sign-up screenrole. - Apple supplies the name only the first time a user authorises the app, so the names are null on later sign-ins.
- Success stores tokens and routes exactly like Google. Dismissing the sheet does nothing. Failures show "Apple Sign In Error" with the message or "An error occurred".
An account created through Google or Apple from the sign-in screen (no role sent) is a tenant, per the comment in the code. Social sign-in does not write local:REMEMBER_ME.
Token storage and refresh
| Item | Where | Lifetime on the device |
|---|---|---|
| Access token | session:ACCESS_TOKEN | Until sign-out, expiry handling, or a launch with Remember me off |
| Refresh token | local:REFRESH_TOKEN | Same |
| User object | local:USER and Redux auth.user | Same |
- Every request sends
Authorization: Bearerwith the access token. - A
401whose message contains "token" triggersPOST /api/v1/auth/refresh-tokenwith the refresh token in the body. This is a barefetch, shared by all in-flight requests. - The new access token replaces
session:ACCESS_TOKEN. The refresh token is not rotated. The failed request is retried once. - If the refresh fails, or the retry returns 401 again,
handleExpiredSessionremoves the three keys, Redux is reset, and the app replaces the route with/(auth)/signin. No message is shown.
Sign out
- On the Profile tab the user taps "Log out". (Tenant profile: see Profile and settings.)
- The
logoutthunk first callsDELETE /api/v1/users/push-tokensfor this device, thenPOST /api/v1/auth/signoutwith the storedrefreshToken. - Whatever the server answers, the thunk removes
session:ACCESS_TOKEN,local:REFRESH_TOKENandlocal:USER, and the store resets every slice and RTK Query cache. - The app replaces the route with
/(auth)/signin.
local:REMEMBER_ME, local:THEME_PREFERENCE and local:TOURS_SEEN are kept after sign-out.
States and edge cases
- Loading. Buttons show a spinner and their in-progress label and are disabled while Redux
auth.loadingis true.loadingis shared, so a resend in progress also disables "Sign in". - Offline or no response. Alerts show "Could not reach the server. Check your connection and try again.". After the 60 second timeout: "The server took too long to respond. It may still have worked -- check before trying again.".
- Social buttons hidden. On Android neither social button shows, and the "or continue with" divider is hidden too.
- Back navigation. The chevron on sign-in calls
router.back(). After a session expiry the sign-in screen was opened withreplace, so there may be nothing to go back to. - Code entry. Pasting a full code into one box does not spread it across boxes; each box accepts one character.
- Sign-in subtitle. The sign-in screen's subtitle talks about managing listings and tenants even when the user is a tenant; the text is the same for all roles.
What happens next
- Tenants land on Home and discovery.
- Agents go to agent onboarding, then the professional tabs.
- As soon as
auth.useris set, the push hook registers the device token. See App launch and onboarding. - The backend emails the verification code on sign-up and on each resend; resend always answers with a generic success message so it cannot be used to test whether an email exists.
App Launch and Onboarding
What happens from a cold start to the first real screen, including session restore, the role redirect, deep links, push notifications and the not-found screen.
Password Reset
The forgot-password flow in the mobile app, from requesting a code by email to setting a new password.
HomeLink Hub