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 <cursoragent@cursor.com>
This commit is contained in:
2026-08-17 21:39:45 +03:30
co-authored by Cursor
parent d57ce0a3cb
commit 357c4fef59
@@ -717,14 +717,23 @@ export class ProgramSettingsService implements OnModuleInit {
if (!apiBase) { if (!apiBase) {
throw new BadRequestException('آدرس API نسخه (node_server) تنظیم نشده'); 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 { try {
const { data } = await axios.post( const res = await axios.post(
url, url,
{ mobile, password }, { provider: 'user', mobile, password },
{ timeout: 25000, validateStatus: () => true }, {
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( throw new BadRequestException(
this.laravelMessage(data) || 'ورود ادمین خانگی ناموفق بود', this.laravelMessage(data) || 'ورود ادمین خانگی ناموفق بود',
); );