From 357c4fef59dfb9dee073c772a45aca4ca7532517 Mon Sep 17 00:00:00 2001 From: adonis Date: Mon, 17 Aug 2026 21:39:45 +0330 Subject: [PATCH] fix(program-settings): log into Khanegi via /auth/login like the admin panel Import was posting to /admin/login without provider=user, so no token came back even with valid credentials. Co-authored-by: Cursor --- .../program-settings.service.ts | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/program-settings/program-settings.service.ts b/src/program-settings/program-settings.service.ts index ca314de..665c6c3 100644 --- a/src/program-settings/program-settings.service.ts +++ b/src/program-settings/program-settings.service.ts @@ -717,14 +717,23 @@ export class ProgramSettingsService implements OnModuleInit { if (!apiBase) { throw new BadRequestException('آدرس API نسخه (node_server) تنظیم نشده'); } - const url = this.joinUrl(apiBase, '/admin/login'); + // همان مسیر پنل ادمین خانگی: POST /auth/login با provider=user + const url = this.joinUrl(apiBase, '/auth/login'); try { - const { data } = await axios.post( + const res = await axios.post( url, - { mobile, password }, - { timeout: 25000, validateStatus: () => true }, + { provider: 'user', mobile, password }, + { + timeout: 25000, + validateStatus: () => true, + headers: { + Accept: 'application/json', + 'Content-Type': 'application/json', + }, + }, ); - if (data?.status === false || data?.success === false) { + const data = res.data; + if (res.status >= 400 || data?.status === false || data?.success === false) { throw new BadRequestException( this.laravelMessage(data) || 'ورود ادمین خانگی ناموفق بود', );