Files
sase.tr/apps/api/drizzle/meta/_journal.json
Semih Yesilyurt 96a9d11015
Some checks failed
QA Gate (P0/P1) / Test affected app (pull_request) Has been cancelled
feat(internal-admin): user lifecycle — suspend / reactivate / ban
Süper Panel Phase 7 — Phase B. Founder can suspend, reactivate, or ban a
Sase user from the panel. Status enforced in the AuthGuard so blocked
users can no longer make authenticated requests.

Schema (migration 0006)
- users.status varchar(20) default 'active' — active|suspended|banned
- users.status_reason text — free-text reason set on transition
- users.status_changed_at, status_changed_by uuid — audit metadata
- users_status_idx

Auth
- AuthGuard rejects 'suspended' / 'banned' with TR-localized message.
- auth.ts: declared `status` as a Better Auth additionalField so the
  session.user object exposes it (matches how `role` is wired).

Endpoints (InternalTokenGuard)
- POST /internal/admin/users/:id/suspend     { reason, founderId }
- POST /internal/admin/users/:id/reactivate  { founderId }
- POST /internal/admin/users/:id/ban         { reason, founderId }

Service
- LifecycleService.setStatus():
  - refuses to touch admin-role users
  - refuses no-op transitions (already in target state)
  - refuses suspended→banned→suspended downgrade path (must reactivate first)
  - on suspend/ban: deletes all sessions for the user (immediate sign-out)
  - returns { from, to, sessionsKilled, changedAt }

Wiring
- LifecycleService + LifecycleController added to InternalAdminModule.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 09:34:52 +03:00

55 lines
1.1 KiB
JSON

{
"version": "7",
"dialect": "postgresql",
"entries": [
{
"idx": 0,
"version": "7",
"when": 1778535325959,
"tag": "0000_brief_guardian",
"breakpoints": true
},
{
"idx": 1,
"version": "7",
"when": 1747039600000,
"tag": "0001_charming_quicksand",
"breakpoints": true
},
{
"idx": 2,
"version": "7",
"when": 1778584574615,
"tag": "0002_boring_the_stranger",
"breakpoints": true
},
{
"idx": 3,
"version": "7",
"when": 1778587000000,
"tag": "0003_query_log_insights",
"breakpoints": true
},
{
"idx": 4,
"version": "7",
"when": 1778709949622,
"tag": "0004_hot_quicksilver",
"breakpoints": true
},
{
"idx": 5,
"version": "7",
"when": 1779054231051,
"tag": "0005_past_elektra",
"breakpoints": true
},
{
"idx": 6,
"version": "7",
"when": 1779086009525,
"tag": "0006_chilly_dark_phoenix",
"breakpoints": true
}
]
}