fixed response data for login,

fixed tabs
This commit is contained in:
2026-02-13 22:01:40 +01:00
parent ae7f05786d
commit 210ab43a0b
2 changed files with 152 additions and 157 deletions

View File

@ -25,6 +25,8 @@ It describes what the project is, what is already implemented, and what still ne
- `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/src/views/AuthView.vue` formatting now uses tab-based indentation.
- Login response parsing in `AuthView` now reads user fields from `response.data.user`.
- Frontend i18n is wired:
- setup in `frontend/src/i18n/index.ts`
- locale files in `frontend/src/locales/{sk,cs,en,es,de}.ts`
@ -34,8 +36,7 @@ It describes what the project is, what is already implemented, and what still ne
- 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`.
- `frontend/src/BackendAPI.ts` is generated via `backend/scripts/buildTypeScript.php` and should not be edited manually.
- `backend/data.json` contains sample meal data (not currently wired into DB/API flow).
## Backend Architecture
@ -139,8 +140,11 @@ All actions are invoked through `backend/public/API.php` with `?action=<method_n
- Some comments in `Maintenance.php` show encoding artifacts, but SQL structure is valid.
- 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.
- APIlite response handling detail:
- raw API response is wrapped as `{ status, data }`
- generated `BackendAPI.ts` currently resolves `response.data` in `callPromise` for non-`__HELP__` actions
- frontend parsing must match the actual returned runtime shape
- `frontend/src/BackendAPI.ts` 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
@ -176,3 +180,4 @@ Frontend:
- Keep MySQL + SQLite compatibility in SQL where possible (project supports both).
- When changing schema, always bump DB version in `Maintenance.php` with forward-only migration steps.
- Keep API action names stable unless frontend is updated at the same time.
- In source files, use tab characters for indentation (do not add space-based indentation).

View File

@ -19,11 +19,13 @@ import { SUPPORTED_LOCALES, type AppLocale } from '@/i18n'
type ThemeMode = 'light' | 'dark'
type LoginResponse = {
data?: {
auto_registered?: boolean
user?: {
email?: string | null
token?: string | null
}
}
}
const { t } = useI18n({ useScope: 'global' })
@ -124,10 +126,13 @@ const submitForm = async () => {
isLoading.value = true
try {
const response = (await BackendAPI.userLogin(normalizedEmail, normalizedPassword)) as LoginResponse
const token = response.user?.token ?? null
const userEmail = response.user?.email ?? normalizedEmail
const response = (await BackendAPI.userLogin(
normalizedEmail,
normalizedPassword,
)) as LoginResponse
const token = response.data?.user?.token ?? null
const userEmail = response.data?.user?.email ?? normalizedEmail
console.log(response)
if (token) {
localStorage.setItem('token', token)
} else {
@ -184,33 +189,18 @@ const submitForm = async () => {
<label for="email">{{ t('auth.emailLabel') }}</label>
<div class="input-wrap">
<font-awesome-icon :icon="faEnvelope" class="input-icon" />
<input
id="email"
v-model="email"
type="email"
autocomplete="email"
:placeholder="t('auth.emailPlaceholder')"
required
/>
<input id="email" v-model="email" type="email" autocomplete="email"
:placeholder="t('auth.emailPlaceholder')" required />
</div>
<label for="password">{{ t('auth.passwordLabel') }}</label>
<div class="input-wrap">
<font-awesome-icon :icon="faLock" class="input-icon" />
<input
id="password"
v-model="password"
:type="showPassword ? 'text' : 'password'"
autocomplete="current-password"
:placeholder="t('auth.passwordPlaceholder')"
required
/>
<button
type="button"
class="password-btn"
<input id="password" v-model="password" :type="showPassword ? 'text' : 'password'"
autocomplete="current-password" :placeholder="t('auth.passwordPlaceholder')" required />
<button type="button" class="password-btn"
:aria-label="showPassword ? t('auth.hidePassword') : t('auth.showPassword')"
@click="showPassword = !showPassword"
>
@click="showPassword = !showPassword">
<font-awesome-icon :icon="showPassword ? faEyeSlash : faEye" />
</button>
</div>