# DemoLogin

A **demo-only** passwordless quick-login page. One screen lists every SaaS
project with curated **role cards** (Admin, Doctor, Nurse, Reception, Accounting,
…); clicking a role signs you in instantly as a demo user holding that role,
scoped to that project's database.

## Enable (demo/QA only — never production)
```
# .env
DEMO_LOGIN=true
```
Every route 404s unless this is true.

## URLs (one page per project)
- **`/demo`** — chooser: one card per project.
- **`/demo/{project}`** — that project's page: a **Normal login** button (→ the
  standard `/login`) **and** that project's one-click demo roles. This is the
  link you hand out per project, e.g. `/demo/shifa`, `/demo/vet`, `/demo/static`.
- `/demo/{project}/login/{role}` — passwordless sign-in as that role.

## How it works
- Projects come from `SaasSwitcher` (`config('saasswitcher.projects')`). Each
  project's `vertical` selects its role cards.
- On click, `DemoLoginController@login`:
  1. switches to the project's DB connection,
  2. ensures the role exists and a `demo_<project>_<role>` user exists (created on
     first use, assigned the role),
  3. records the active project in the session (the keys
     `SaasSwitcher`'s `ResolveProjectConnection` reads) and `Auth::login`s,
  4. redirects to `/home`.
- Admin uses the `Admin#<biz>` role (full access via the core Gate bypass);
  other roles rely on the permissions seeded by the clinic/vet
  `DefaultRolesSeeder`s, so each role sees a realistically scoped app.

## Add / change roles  (future-proof)
- **New project** → just add it to `SaasSwitcher` with a `vertical`; it appears
  here automatically with that vertical's role cards.
- **New vertical** or **new role** → edit `Config/config.php` → `role_sets`.
  `role` is the Spatie role base name (suffixed with the business id at runtime,
  e.g. `Doctor` → `Doctor#8`); it must exist in the project DB (or it is created
  empty on first use).

## Zero core-script changes
Entirely self-contained under `Modules/DemoLogin` (depends on `SaasSwitcher`).
Disable by removing `DEMO_LOGIN` (or setting it false), or set
`"DemoLogin": false` in `modules_statuses.json`.
