# Users and your app's own data

> Why an auth user holds only identity and sessions, where your app keeps profiles and roles, and how several apps share one sign-in.

Applies to: the Sypnia engine (open source, self-hosted) and Sypnia Cloud (paid service).  
Source: https://data.docs.sypnia.com/auth/users-and-your-data/

For agents: Pattern: sypnia_auth.users holds identity/session only (email, password hash, identities, metadata). Keep profiles, roles, plans and teams in your own tables keyed by user id (references sypnia_auth.users(id)). 'Roll-in': the first time a signed-in identity opens your app or a second product, create its row idempotently (insert … on conflict do nothing). Several apps on one domain can share a session with a refresh-token cookie on the parent domain and silent refresh; each app verifies access tokens with the project's JWKS.

## Identity here, everything else in your tables

`sypnia_auth.users` answers one question: _who is this?_ It does not know your app's plans, teams, roles or settings, on purpose. Keep those in your own tables, keyed by the user's id:

```sql
create table public.members (
  user_id uuid primary key references sypnia_auth.users(id) on delete cascade,
  display_name text,
  role text not null default 'member',      -- your app's role, not a database role
  created_at timestamptz not null default now()
);
```

Your app grows its own model freely, and the same identity can be used by several apps without one app's data leaking into another's.

## Roll-in: the first visit

When a signed-in person opens your app for the first time, create their row there. Make it idempotent, so it can run on every visit:

```sql
insert into public.members (user_id, display_name)
values (auth.uid(), auth.jwt() -> 'user_metadata' ->> 'name')
on conflict (user_id) do nothing;
```

If you write your app as use cases ([Sypnorm, with Cases](https://cases.docs.sypnia.com/sypnorm/)), this is a use case of its own, `JoinApp`, and your onboarding follows it. No second sign-up, no second password.

## Several apps, one sign-in

Apps on the same domain (`shop.example.com`, `admin.example.com`) can share one session:

1. Turn on **cross-subdomain sessions** for the project and set the parent domain (`.example.com`). After a sign-in, the engine sets the refresh token in an `HttpOnly`, `Secure`, `SameSite=Lax` cookie on that domain, plus a harmless hint cookie the apps can read.
2. Each app, when it starts, calls `refresh` with `credentials: 'include'` and a CSRF header (the double-submit cookie the engine sets). If the cookie is there, it gets an access token without showing a sign-in screen.
3. Each app keeps the access token in memory and its own server verifies it with the project's JWKS.
4. Signing out with `scope: 'global'` clears the cookie for every app.

Each app keeps its own sign-in and sign-up screens, so it also works alone; when the session already exists, the person goes straight to the app.
