Skip to Content
HomeLink Hub

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

ScreenRouteFileWho sees it
Auth stacknoneapp/(auth)/_layout.tsxSigned-out users
Sign up/signupapp/(auth)/signup.tsxSigned-out users
Confirm your Email/confirm-emailapp/(auth)/confirm-email.tsxNew accounts, and password reset
Sign in/signinapp/(auth)/signin.tsxSigned-out users, and anyone whose session expired
Check mail/check-mailapp/(auth)/check-mail.tsxNobody (placeholder)
Verify email/verify-emailapp/(auth)/verify-email.tsxNobody (placeholder)
Google callback/google-callbackapp/(auth)/google-callback.tsxNobody (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

  1. 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".
  2. Under "I want to", the user picks an account type. "Find a home" (default) sends role: "TENANT"; "List properties" sends role: "AGENT". Landlord, lawyer and developer accounts cannot be created from the app.
  3. The user fills in three fields:
FieldRule in the appRule on the server
Full NameRequired. 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 AddressRequired. Trimmed.Valid email, lowercased
PasswordRequired. No length check in the app.8 to 128 characters
  1. 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.".
  2. Otherwise the app fires POST /api/v1/auth/signup with firstName, lastName, email, password, role and isMobile: true. The button reads "Creating account..." while Redux auth.loading is true.
  3. On success a toast shows "Account Created!" / "A verification code has been sent to your email." and the app pushes /confirm-email with params email (lowercased) and purpose set to signup. Nothing is stored yet; the user is not signed in.
  4. 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

  1. 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.
  2. "Confirm" with fewer than four digits shows "Error" / "Please enter the complete 4-digit code.".
  3. With purpose set to signup the app fires POST /api/v1/auth/verify-email-otp with email and code. The button reads "Verifying...".
  4. 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.
  5. 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.".
  6. 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-verification with email and isMobile: 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

  1. The screen is titled "Welcome Back!". Fields: "Email Address" and "Password" (with a show or hide eye icon).
  2. "Remember me" is a checkbox, off by default. "Forgot Password?" pushes /password-reset.
  3. "Sign in" with either field blank shows "Error" / "Please enter both email and password.".
  4. Otherwise the app fires POST /api/v1/auth/signin with email (trimmed) and password. The button reads "Signing in...".
  5. On success the thunk stores:
    • session:ACCESS_TOKEN (access token)
    • local:REFRESH_TOKEN (refresh token)
    • local:USER (the user object)
    • Redux auth.user
  6. The screen then writes the checkbox value to local:REMEMBER_ME and replaces the route with postAuthRouteForRole(role): /tenant for tenants, /agent-onboarding for agents, /(tabs) for landlords, lawyers and developers.
  7. If the server rejects with errorData.code equal to EMAIL_NOT_VERIFIED, the app immediately fires POST /api/v1/auth/resend-verification, shows the info toast "Verify your email" / "We've sent a verification code to your email.", and pushes /confirm-email with purpose set to signup. 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.".
  8. Any other failure shows "Sign In Failed" with the server message or "Could not sign in. Please verify your credentials.".

Continue with Google

  1. 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).
  2. Tapping it opens Google's native account sheet. The app takes the returned ID token and fires POST /api/v1/auth/google/native with idToken. From the sign-up screen it also sends role (the selected account type), which applies only if this creates a new account.
  3. Success stores the same three AsyncStorage keys as email sign-in and routes by the role the server returned.
  4. 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

  1. Apple's own "Continue with Apple" button (black in light mode, white in dark mode) shows on iOS when available.
  2. The system sheet asks for name and email. The app sends POST /api/v1/auth/apple/native with identityToken, authorizationCode, firstName, lastName, and from the sign-up screen role.
  3. Apple supplies the name only the first time a user authorises the app, so the names are null on later sign-ins.
  4. 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

ItemWhereLifetime on the device
Access tokensession:ACCESS_TOKENUntil sign-out, expiry handling, or a launch with Remember me off
Refresh tokenlocal:REFRESH_TOKENSame
User objectlocal:USER and Redux auth.userSame
  1. Every request sends Authorization: Bearer with the access token.
  2. A 401 whose message contains "token" triggers POST /api/v1/auth/refresh-token with the refresh token in the body. This is a bare fetch, shared by all in-flight requests.
  3. The new access token replaces session:ACCESS_TOKEN. The refresh token is not rotated. The failed request is retried once.
  4. If the refresh fails, or the retry returns 401 again, handleExpiredSession removes the three keys, Redux is reset, and the app replaces the route with /(auth)/signin. No message is shown.

Sign out

  1. On the Profile tab the user taps "Log out". (Tenant profile: see Profile and settings.)
  2. The logout thunk first calls DELETE /api/v1/users/push-tokens for this device, then POST /api/v1/auth/signout with the stored refreshToken.
  3. Whatever the server answers, the thunk removes session:ACCESS_TOKEN, local:REFRESH_TOKEN and local:USER, and the store resets every slice and RTK Query cache.
  4. 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.loading is true. loading is 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 with replace, 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.user is 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.

On this page