fixed response data for login,
fixed tabs
This commit is contained in:
13
AGENTS.md
13
AGENTS.md
@ -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`.
|
- `frontend/src/router/index.ts` maps `/` to `frontend/src/views/AuthView.vue`.
|
||||||
- `AuthView` serves as login + registration entry (single form, email + password).
|
- `AuthView` serves as login + registration entry (single form, email + password).
|
||||||
- Successful login stores `token` and `user_email` in `localStorage`.
|
- 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:
|
- Frontend i18n is wired:
|
||||||
- setup in `frontend/src/i18n/index.ts`
|
- setup in `frontend/src/i18n/index.ts`
|
||||||
- locale files in `frontend/src/locales/{sk,cs,en,es,de}.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).
|
- 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`).
|
- 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`.
|
- 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.ts` 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/data.json` contains sample meal data (not currently wired into DB/API flow).
|
||||||
|
|
||||||
## Backend Architecture
|
## 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.
|
- 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.
|
- 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.
|
- 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.
|
- APIlite response handling detail:
|
||||||
- `frontend/src/BackendAPI.js` is generated output; regenerate when backend API changes, do not patch manually.
|
- 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.
|
- In vue-i18n locale strings, `@` must be escaped as `{'@'}` to avoid "Invalid linked format" errors.
|
||||||
|
|
||||||
## Local Runbook
|
## Local Runbook
|
||||||
@ -176,3 +180,4 @@ Frontend:
|
|||||||
- Keep MySQL + SQLite compatibility in SQL where possible (project supports both).
|
- 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.
|
- 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.
|
- 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).
|
||||||
|
|||||||
@ -19,12 +19,14 @@ import { SUPPORTED_LOCALES, type AppLocale } from '@/i18n'
|
|||||||
type ThemeMode = 'light' | 'dark'
|
type ThemeMode = 'light' | 'dark'
|
||||||
|
|
||||||
type LoginResponse = {
|
type LoginResponse = {
|
||||||
|
data?: {
|
||||||
auto_registered?: boolean
|
auto_registered?: boolean
|
||||||
user?: {
|
user?: {
|
||||||
email?: string | null
|
email?: string | null
|
||||||
token?: string | null
|
token?: string | null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const { t } = useI18n({ useScope: 'global' })
|
const { t } = useI18n({ useScope: 'global' })
|
||||||
|
|
||||||
@ -124,10 +126,13 @@ const submitForm = async () => {
|
|||||||
|
|
||||||
isLoading.value = true
|
isLoading.value = true
|
||||||
try {
|
try {
|
||||||
const response = (await BackendAPI.userLogin(normalizedEmail, normalizedPassword)) as LoginResponse
|
const response = (await BackendAPI.userLogin(
|
||||||
const token = response.user?.token ?? null
|
normalizedEmail,
|
||||||
const userEmail = response.user?.email ?? normalizedEmail
|
normalizedPassword,
|
||||||
|
)) as LoginResponse
|
||||||
|
const token = response.data?.user?.token ?? null
|
||||||
|
const userEmail = response.data?.user?.email ?? normalizedEmail
|
||||||
|
console.log(response)
|
||||||
if (token) {
|
if (token) {
|
||||||
localStorage.setItem('token', token)
|
localStorage.setItem('token', token)
|
||||||
} else {
|
} else {
|
||||||
@ -184,33 +189,18 @@ const submitForm = async () => {
|
|||||||
<label for="email">{{ t('auth.emailLabel') }}</label>
|
<label for="email">{{ t('auth.emailLabel') }}</label>
|
||||||
<div class="input-wrap">
|
<div class="input-wrap">
|
||||||
<font-awesome-icon :icon="faEnvelope" class="input-icon" />
|
<font-awesome-icon :icon="faEnvelope" class="input-icon" />
|
||||||
<input
|
<input id="email" v-model="email" type="email" autocomplete="email"
|
||||||
id="email"
|
:placeholder="t('auth.emailPlaceholder')" required />
|
||||||
v-model="email"
|
|
||||||
type="email"
|
|
||||||
autocomplete="email"
|
|
||||||
:placeholder="t('auth.emailPlaceholder')"
|
|
||||||
required
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<label for="password">{{ t('auth.passwordLabel') }}</label>
|
<label for="password">{{ t('auth.passwordLabel') }}</label>
|
||||||
<div class="input-wrap">
|
<div class="input-wrap">
|
||||||
<font-awesome-icon :icon="faLock" class="input-icon" />
|
<font-awesome-icon :icon="faLock" class="input-icon" />
|
||||||
<input
|
<input id="password" v-model="password" :type="showPassword ? 'text' : 'password'"
|
||||||
id="password"
|
autocomplete="current-password" :placeholder="t('auth.passwordPlaceholder')" required />
|
||||||
v-model="password"
|
<button type="button" class="password-btn"
|
||||||
: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')"
|
:aria-label="showPassword ? t('auth.hidePassword') : t('auth.showPassword')"
|
||||||
@click="showPassword = !showPassword"
|
@click="showPassword = !showPassword">
|
||||||
>
|
|
||||||
<font-awesome-icon :icon="showPassword ? faEyeSlash : faEye" />
|
<font-awesome-icon :icon="showPassword ? faEyeSlash : faEye" />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user