add auto-signup login and localized auth UI

- backend: userLogin auto-registers missing users and returns auto_registered
- frontend: add responsive auth page (login + signup flow via userLogin) with light/dark mode and logo
- i18n: wire language switching, add translations for cs/en/es/de
- ui/tooling: add Font Awesome integration
This commit is contained in:
2026-02-13 07:55:37 +01:00
parent 2d96baa389
commit 64a8ac047f
21 changed files with 1168 additions and 17 deletions

View File

@ -15,14 +15,27 @@ It describes what the project is, what is already implemented, and what still ne
- `backend/`
- `frontend/`
## Current State (as of 2026-02-12)
## Current State (as of 2026-02-13)
- `README.md` already contains product specification in Slovak and English.
- Backend DB migrations exist in `backend/src/Maintenance.php` up to version `7`.
- Backend API methods are implemented in `backend/src/API.php`.
- Frontend is still template-level:
- `frontend/src/App.vue` has placeholder content.
- `frontend/src/router/index.ts` has empty `routes: []`.
- Frontend auth page is now implemented:
- `frontend/src/App.vue` renders router view.
- `frontend/src/router/index.ts` maps `/` to `frontend/src/views/AuthView.vue`.
- `AuthView` serves as login + registration entry (single form, email + password).
- Successful login stores `token` and `user_email` in `localStorage`.
- Frontend i18n is wired:
- setup in `frontend/src/i18n/index.ts`
- locale files in `frontend/src/locales/{sk,cs,en,es,de}.ts`
- language switcher updates locale dynamically.
- Frontend theme system is implemented:
- light/dark mode toggle in auth page
- design tokens in `frontend/src/assets/css/style.css` (`:root` variables).
- App logo is served from `frontend/public/Nutrio.png` (copied from `doc/Nutrio.png`).
- Font Awesome is installed and registered globally in `frontend/src/main.ts`.
- `frontend/src/BackendAPI.js` is generated via `backend/scripts/buildTypeScript.php` and should not be edited manually.
- `frontend/src/BackendAPI.d.ts` provides TS declarations for generated `BackendAPI.js`.
- `backend/data.json` contains sample meal data (not currently wired into DB/API flow).
## Backend Architecture
@ -111,6 +124,11 @@ All actions are invoked through `backend/public/API.php` with `?action=<method_n
- ingredients can be user-owned or global (`user_id = null`) for read/select
- Registration/login generate and store user token in DB.
- `userLogout(token)` invalidates session by setting `token` and `token_expires` to `NULL`.
- `userLogin(email, password)` now auto-registers user when:
- email is valid
- user does not exist
- then proceeds with normal login/token generation flow
- `userLogin` response now includes `auto_registered` flag (`true|false`).
## Known Pitfalls and Notes
@ -122,6 +140,8 @@ All actions are invoked through `backend/public/API.php` with `?action=<method_n
- Basic token auth is implemented, but token is still passed as plain API parameter.
- For `array` parameters (for example `ordered_item_ids`), APIlite expects JSON in request payload.
- APIlite wraps responses with a nested `data` object. Keep this in mind on frontend parsing.
- `frontend/src/BackendAPI.js` is generated output; regenerate when backend API changes, do not patch manually.
- In vue-i18n locale strings, `@` must be escaped as `{'@'}` to avoid "Invalid linked format" errors.
## Local Runbook
@ -132,6 +152,8 @@ Backend:
- configure DB via `backend/config/*.php` override
- serve `backend/public` through web server/PHP runtime
- first API hit triggers `Maintenance->database()` migration flow
- when backend API signature changes, regenerate frontend API client:
- `php scripts/buildTypeScript.php`
Frontend:
@ -143,7 +165,7 @@ Frontend:
## Product Behavior Target (what to build next)
- Harden auth (token transport/header strategy, token revoke strategy, brute-force/rate-limits).
- Build frontend screens for ingredients, meals, meal item editor, diary day, diary range.
- Build remaining frontend screens for ingredients, meals, meal item editor, diary day, diary range.
- Connect frontend to implemented backend actions.
- Add API tests for validation, ownership checks, and totals calculation consistency.
- Add pagination/filter strategy where list endpoints grow.