Commit Graph
66 Commits
Author SHA1 Message Date
Parsa Aghayi 3f386c7be8 Add the admin content API the CMS needs
Two gaps blocked building the admin panel:

About-me writes could only set the image. Title and description live in the
JSON translations column and were unreachable from the API, so the homepage
bio could never be edited through the app. Accept title_fa/title_en/
description_fa/description_en on both About Me form requests and write them
per locale through setTranslation().

Editing also needs raw rows. The public project and about-me endpoints only
return display-oriented payloads - one translated title, reshaped image
arrays, no second locale - which is not enough to populate a form. Add
GET /api/admin/resources/{resource} behind the same auth:sanctum + admin
middleware as the write routes, returning stored rows including every locale,
plus a public GET /api/website/project-categories so project forms have a
category picker.

Covered by AdminResourceReadTest: anonymous and non-admin callers are
rejected for every resource, unknown resource names 404, and project rows
expose both locales.
2026-10-01 15:28:23 -04:00
root 8b834189a4 Close anonymous write access to the public API and repair the broken test suite
Every mutating endpoint was reachable without authentication, so any visitor
could create, edit or delete posts, categories, tags, projects and about-me
records on the live site.

Security
- Split routes into an anonymous read-only group and a write group gated by
  `auth:sanctum` + a new `admin` middleware.
- Add `is_admin` to users; Sanctum token support on the User model.
- Add AuthController (login / me / logout). The Sanctum token is delivered in
  an httpOnly cookie and never returned in the JSON body, because the admin
  panel reaches the API through a Next.js server-side proxy that breaks
  Sanctum's first-party domain detection.
- AuthenticateAdminPanelSession promotes that cookie to a bearer header so
  Sanctum's normal validation, expiry and revocation still apply.
- Remove the unauthenticated `/user/{id}` route, which exposed user emails.
- Non-admin accounts are refused at login and the failure shape is identical
  to a bad password, so the endpoint cannot enumerate accounts.
- Fix `Route [login] not defined`: a non-JSON unauthenticated request resolved
  a route that does not exist in this API-only app and returned 500.
- Reject invalid list query parameters with 422 instead of 500, and cap
  per_page at 50 (`?per_page=100000` previously dumped whole tables).

Correctness
- Make the translation migration portable. It used MySQL-only JSON_OBJECTAGG,
  which aborted all 29 tests during migration; the data collapse now runs in
  PHP so it works on MySQL, MariaDB and SQLite.
- Add HasJsonTranslations trait providing the missing setTranslation(), which
  made project create/update return 500, and replace five copy-pasted
  getTranslation()/hasTranslation() bodies.
- Make posts.excerpt nullable to match StorePostRequest; omitting an excerpt
  was a guaranteed SQL integrity error.
- Route the AboutMeController CRUD methods that existed but were never
  registered.
- CategoryTest omitted a required description; fixed the test, the existing
  schema and validation already agreed.

Tests: 83 passing / 126 assertions (was 29 failing / 0 assertions)
2026-10-01 14:35:34 -04:00
parsa aghaei 35686d82c3 chore: remove Iranian mirror from CI workflow - use official Alpine repos
Deploy Backend / deploy (push) Failing after 13s
2026-07-12 13:35:32 +03:30
parsa aghaei ab0e9517ea chore: remove committed vendor directory from git
- Remove vendor/ from git tracking
- Uncomment /vendor in .gitignore to prevent future commits
- Dependencies will be installed via CI/CD with VPN + Nexus cache
2026-07-12 13:28:08 +03:30
DevOps 6366843e47 test: trigger backend CI/CD pipeline 2026-06-28 18:09:20 +00:00
DevOps 1a75055dd9 fix: add missing hasTranslation method to AboutMe model 2026-06-28 17:41:38 +00:00
DevOps 223a4f5640 fix: remove HasTranslations trait, use translations JSON in models + seeders 2026-06-28 17:37:08 +00:00
parsa aghaei ebd4bd19ed content: update about and service seeders with professional senior engineer copy 2026-06-28 20:22:12 +03:30
DevOps 4c5f6cfe10 fix: update Service model for translations JSON column 2026-06-28 15:59:20 +00:00
DevOps 1b2e73bc0e cleanup: remove trigger, fix .dockerignore 2026-06-28 15:45:15 +00:00
DevOps b659d267cb test: trigger CI/CD with offline vendor build 2026-06-28 13:46:04 +00:00
parsa aghaei d86aef2bec fix: remove ENV HTTP_PROXY, offline install when vendor exists 2026-06-28 16:56:28 +03:30
parsa aghaei 6b81bf0afe fix: only set composer proxy when vendor absent, use offline install otherwise 2026-06-28 16:52:12 +03:30
parsa aghaei 59a8d1f82b chore: commit vendor for offline build 2026-06-28 16:47:17 +03:30
DevOps 7f44e5d33a chore: add vendor for offline builds 2026-06-28 12:47:12 +00:00
DevOps 0e1ac38cf1 final test - nexus mirrors 2026-06-28 11:37:54 +00:00
DevOps 4584645518 restore Nexus mirror, test CI/CD 2026-06-28 10:51:19 +00:00
DevOps ff1fc2afd0 fix: remove Nexus mirror, use packagist.org directly via proxy 2026-06-28 10:30:23 +00:00
DevOps e841c89444 retry ci - symfony/routing 400 transient 2026-06-28 10:27:41 +00:00
DevOps 11ebd658e4 trigger ci - test proxy 2026-06-28 10:25:12 +00:00
parsa aghaei 110d4e0ed3 trigger ci - test optimized build 2026-06-28 13:40:57 +03:30
parsa aghaei f951e19ffb trigger ci backend - test proxy 2026-06-28 12:25:14 +03:30
parsa aghaei b31b4d73ac upgrade: Laravel 13 + swagger-php v6 attributes 2026-06-28 12:01:57 +03:30
parsa aghaei f7ad5f6844 trigger ci 2026-06-28 11:11:43 +03:30
parsa aghaei 7935eb7f62 trigger ci 2026-06-27 14:07:38 +03:30
parsa aghaei 91d5398702 fix: use arvancloud Alpine mirror (Liara returns 500), remove unused proxy 2026-06-27 11:38:22 +03:30
parsa aghaei 7d8c125a39 fix: revert Alpine mirror to Liara (CI containers cant reach Nexus) 2026-06-27 11:32:21 +03:30
parsa aghaei fd5c10572d chore: trigger CI test 2026-06-27 11:22:56 +03:30
parsa aghaei bfffd46f4e Switch Alpine mirror to Nexus proxy registry.parsaaghayi.ir 2026-06-27 11:00:46 +03:30
parsa aghaei 4d10cbf13d fix deploy: revert to Liara mirror + add http proxy 172.17.0.1:3001 2026-06-27 09:51:45 +03:30
parsa aghaei 8025dd9197 fix deploy: use default package manager repos instead of broken mirror 2026-06-27 09:41:17 +03:30
parsa aghaei 86de286e46 replace default Laravel welcome page with professional API landing page 2026-06-27 09:39:38 +03:30
parsa aghaei e9601a91af test file added for testing cicd 2026-06-23 20:10:46 +03:30
parsa aghaei e3e5033fec fix: add json translation columns migration, re-add /vendor to .gitignore 2026-06-23 20:00:35 +03:30
parsa aghaei db0cf119ab fix: remove /vendor from .gitignore (vendor committed to git) 2026-06-23 19:40:24 +03:30
parsa aghaei 78a14646eb 6.1-6.2: fix seeders for spatie translatable, uncomment ProjectSeeder, order correctly 2026-06-23 19:23:44 +03:30
parsa aghaei 9ff5b93157 4.1-4.3: add PHPUnit feature tests for all endpoints + factories 2026-06-23 18:37:14 +03:30
parsa aghaei afb202f333 3.1-3.6: install l5-swagger, add @OA annotations to all controllers 2026-06-23 18:34:20 +03:30
parsa aghaei db7ce880a0 2.1-2.4: install spatie/laravel-translatable, migrate to JSON, update models & controllers 2026-06-23 18:31:51 +03:30
parsa aghaei 1dc72d8563 1.3: fix N+1 in getTranslation by using eager-loaded collection 2026-06-23 18:10:22 +03:30
parsa aghaei 28c7a317e5 1.2: restructure controllers to Api/ prefix and update routes 2026-06-23 18:09:15 +03:30
parsa aghaei cbcccfcbf8 1.1: remove dead code - old models and controllers 2026-06-23 18:07:38 +03:30
parsa aghaei 4cfbb05baf 0.4: apply throttle:60,1 to public API routes 2026-06-23 18:06:52 +03:30
parsa aghaei faea1759cf 0.2: restrict CORS allowed_origins to FRONTEND_URL 2026-06-23 18:05:27 +03:30
parsa aghaei f3568ab277 0.1: replace Request with FormRequest in all controllers 2026-06-23 18:04:57 +03:30
DevOps ffafcf447b test: full pipeline deploy 2026-06-23 12:28:00 +00:00
DevOps 8de63a61f3 ci: vendor injection for offline composer install 2026-06-23 12:10:52 +00:00
DevOps 728716c589 ci: trigger backend deploy with Liara composer mirror 2026-06-23 12:01:36 +00:00
devops ea03954a84 fix deploy: use Liara Alpine mirror for apk 2026-06-23 11:26:52 +00:00
devops 2e769bfece fix deploy: use sh shell (alpine has no bash) 2026-06-23 11:20:40 +00:00