Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

feat(dashboard): warn before a phone pairing code is requested

Yudhi Armyndharis918406dea31d
diff --git a/dashboard/src/i18n/locales/ar.json b/dashboard/src/i18n/locales/ar.json
index 246d53c2e..012fd1873 100644
--- a/dashboard/src/i18n/locales/ar.json
+++ b/dashboard/src/i18n/locales/ar.json
@@ -390,6 +390,7 @@
"phoneLabel": "رقم الهاتف",
"phonePlaceholder": "مثال: 919876543210",
"phoneHint": "أرقام فقط (بدون + أو مسافات أو شرطات) بالصيغة الدولية (رمز الدولة + الرقم).",
+ "relinkWarning": "على محرك whatsapp-web.js، قد يؤدي طلب رمز لرقم له جلسة مرتبطة بالفعل إلى قيام واتساب بإلغاء ربط ذلك الجهاز. استخدم تبويب رمز QR إذا كان يجب أن تبقى تلك الجلسة تعمل.",
"invalidPhone": "أدخل رقم هاتف صالحاً: من 6 إلى 15 رقماً، يبدأ برمز الدولة، بدون رموز.",
"generateButton": "إنشاء رمز الربط",
"generating": "جارٍ إنشاء رمز الربط...",
diff --git a/dashboard/src/i18n/locales/de.json b/dashboard/src/i18n/locales/de.json
index 03288c8c3..221b4118a 100644
--- a/dashboard/src/i18n/locales/de.json
+++ b/dashboard/src/i18n/locales/de.json
@@ -379,6 +379,7 @@
"phoneLabel": "Telefonnummer",
"phonePlaceholder": "z. B. 491701234567",
"phoneHint": "Nur Ziffern im internationalen Format (Ländervorwahl + Nummer), ohne +, Leerzeichen oder Bindestriche.",
+ "relinkWarning": "Auf der whatsapp-web.js-Engine kann eine Code-Anfrage für eine Nummer, die bereits eine verknüpfte Sitzung hat, dazu führen, dass WhatsApp dieses Gerät trennt. Nutze den QR-Tab, wenn diese Sitzung aktiv bleiben muss.",
"invalidPhone": "Gib eine gültige Telefonnummer ein: 6–15 Ziffern, zuerst die Ländervorwahl, keine Sonderzeichen.",
"generateButton": "Kopplungscode erstellen",
"generating": "Kopplungscode wird erstellt...",
diff --git a/dashboard/src/i18n/locales/en.json b/dashboard/src/i18n/locales/en.json
index d1add9ef7..c7b82982d 100644
--- a/dashboard/src/i18n/locales/en.json
+++ b/dashboard/src/i18n/locales/en.json
@@ -384,6 +384,7 @@
"phoneLabel": "Phone Number",
"phonePlaceholder": "e.g., 919876543210",
"phoneHint": "Digits only (no +, spaces, or dashes) in international format (country code + number).",
+ "relinkWarning": "On the whatsapp-web.js engine, requesting a code for a number that already has a linked session can make WhatsApp unlink that device. Use the QR tab if that session must stay up.",
"invalidPhone": "Enter a valid phone number: 6–15 digits, country code first, no symbols.",
"generateButton": "Generate Pairing Code",
"generating": "Generating pairing code...",
diff --git a/dashboard/src/i18n/locales/es.json b/dashboard/src/i18n/locales/es.json
index 6e4dcf35d..7f0dd9229 100644
--- a/dashboard/src/i18n/locales/es.json
+++ b/dashboard/src/i18n/locales/es.json
@@ -379,6 +379,7 @@
"phoneLabel": "Número de teléfono",
"phonePlaceholder": "ej., 919876543210",
"phoneHint": "Solo dígitos (sin +, espacios ni guiones) en formato internacional (código de país + número).",
+ "relinkWarning": "En el motor whatsapp-web.js, pedir un código para un número que ya tiene una sesión vinculada puede hacer que WhatsApp desvincule ese dispositivo. Usa la pestaña de código QR si esa sesión debe seguir activa.",
"invalidPhone": "Introduce un número de teléfono válido: 6-15 dígitos, primero el código de país, sin símbolos.",
"generateButton": "Generar código de vinculación",
"generating": "Generando código de vinculación...",
diff --git a/dashboard/src/i18n/locales/fr.json b/dashboard/src/i18n/locales/fr.json
index 1b5e82ab0..2a10fca79 100644
--- a/dashboard/src/i18n/locales/fr.json
+++ b/dashboard/src/i18n/locales/fr.json
@@ -379,6 +379,7 @@
"phoneLabel": "Numéro de téléphone",
"phonePlaceholder": "ex. : 919876543210",
"phoneHint": "Chiffres uniquement (sans +, espaces ni tirets) au format international (indicatif du pays + numéro).",
+ "relinkWarning": "Sur le moteur whatsapp-web.js, demander un code pour un numéro qui a déjà une session liée peut amener WhatsApp à dissocier cet appareil. Utilisez l'onglet QR si cette session doit rester active.",
"invalidPhone": "Saisissez un numéro de téléphone valide : 6 à 15 chiffres, indicatif du pays en premier, sans symboles.",
"generateButton": "Générer le code de liaison",
"generating": "Génération du code de liaison...",
diff --git a/dashboard/src/i18n/locales/he.json b/dashboard/src/i18n/locales/he.json
index 21625a20f..93780beef 100644
--- a/dashboard/src/i18n/locales/he.json
+++ b/dashboard/src/i18n/locales/he.json
@@ -386,6 +386,7 @@
"phoneLabel": "מספר טלפון",
"phonePlaceholder": "לדוגמה: 919876543210",
"phoneHint": "ספרות בלבד (ללא +, רווחים או מקפים) בפורמט בין-לאומי (קידומת מדינה + מספר).",
+ "relinkWarning": "במנוע whatsapp-web.js, בקשת קוד עבור מספר שכבר יש לו סשן מקושר עלולה לגרום לוואטסאפ לנתק את המכשיר הזה. השתמשו בלשונית ה-QR אם הסשן הזה חייב להישאר פעיל.",
"invalidPhone": "יש להזין מספר טלפון תקין: 6–15 ספרות, קידומת המדינה תחילה, ללא סימנים.",
"generateButton": "יצירת קוד קישור",
"generating": "יוצר קוד קישור...",
diff --git a/dashboard/src/i18n/locales/it.json b/dashboard/src/i18n/locales/it.json
index 8b4c3e4b0..37e6270c9 100644
--- a/dashboard/src/i18n/locales/it.json
+++ b/dashboard/src/i18n/locales/it.json
@@ -379,6 +379,7 @@
"phoneLabel": "Numero di Telefono",
"phonePlaceholder": "es., 919876543210",
"phoneHint": "Solo cifre (senza +, spazi o trattini) in formato internazionale (prefisso del paese + numero).",
+ "relinkWarning": "Sul motore whatsapp-web.js, richiedere un codice per un numero che ha già una sessione collegata può far sì che WhatsApp scolleghi quel dispositivo. Usa la scheda QR se quella sessione deve restare attiva.",
"invalidPhone": "Inserisci un numero di telefono valido: 6–15 cifre, prefisso del paese per primo, senza simboli.",
"generateButton": "Genera codice di abbinamento",
"generating": "Generazione del codice di abbinamento in corso...",
diff --git a/dashboard/src/i18n/locales/ko.json b/dashboard/src/i18n/locales/ko.json
index 7949c7a97..e75a1e0bf 100644
--- a/dashboard/src/i18n/locales/ko.json
+++ b/dashboard/src/i18n/locales/ko.json
@@ -379,6 +379,7 @@
"phoneLabel": "전화번호",
"phonePlaceholder": "예: 919876543210",
"phoneHint": "국제 형식(국가 코드 + 번호)으로 숫자만 입력하세요(+, 공백, 하이픈 제외).",
+ "relinkWarning": "whatsapp-web.js 엔진에서는 이미 연결된 세션이 있는 번호로 코드를 요청하면 WhatsApp이 해당 기기의 연결을 해제할 수 있습니다. 그 세션을 유지해야 한다면 QR 탭을 사용하세요.",
"invalidPhone": "올바른 전화번호를 입력하세요: 6~15자리 숫자, 국가 코드로 시작, 기호 없이.",
"generateButton": "페어링 코드 생성",
"generating": "페어링 코드를 생성하는 중...",
diff --git a/dashboard/src/i18n/locales/pt-BR.json b/dashboard/src/i18n/locales/pt-BR.json
index fbdf08fd3..a29438377 100644
--- a/dashboard/src/i18n/locales/pt-BR.json
+++ b/dashboard/src/i18n/locales/pt-BR.json
@@ -379,6 +379,7 @@
"phoneLabel": "Número de telefone",
"phonePlaceholder": "ex.: 919876543210",
"phoneHint": "Apenas dígitos (sem +, espaços ou hífens) no formato internacional (código do país + número).",
+ "relinkWarning": "No motor whatsapp-web.js, solicitar um código para um número que já tem uma sessão vinculada pode fazer o WhatsApp desvincular esse dispositivo. Use a aba de QR code se essa sessão precisar continuar ativa.",
"invalidPhone": "Informe um número de telefone válido: 6–15 dígitos, com o código do país primeiro e sem símbolos.",
"generateButton": "Gerar código de conexão",
"generating": "Gerando código de conexão...",
diff --git a/dashboard/src/i18n/locales/te.json b/dashboard/src/i18n/locales/te.json
index 395aaa079..159c13143 100644
--- a/dashboard/src/i18n/locales/te.json
+++ b/dashboard/src/i18n/locales/te.json
@@ -379,6 +379,7 @@
"phoneLabel": "ఫోన్ నంబర్",
"phonePlaceholder": "ఉదాహరణకు, 919876543210",
"phoneHint": "అంతర్జాతీయ ఆకృతిలో (కంట్రీ కోడ్ + నంబర్) సంఖ్యలు మాత్రమే (+, ఖాళీలు, లేదా డాష్‌లు లేకుండా).",
+ "relinkWarning": "whatsapp-web.js ఇంజిన్‌లో, ఇప్పటికే లింక్ చేసిన సెషన్ ఉన్న నంబర్‌కు కోడ్ అడిగితే WhatsApp ఆ పరికరం లింక్‌ను తొలగించవచ్చు. ఆ సెషన్ కొనసాగాలంటే QR ట్యాబ్‌ను వాడండి.",
"invalidPhone": "చెల్లుబాటు అయ్యే ఫోన్ నంబర్‌ను నమోదు చేయండి: 6–15 సంఖ్యలు, ముందుగా కంట్రీ కోడ్, ఎలాంటి చిహ్నాలు లేకుండా.",
"generateButton": "పెయిరింగ్ కోడ్‌ను రూపొందించండి",
"generating": "పెయిరింగ్ కోడ్‌ను రూపొందిస్తోంది...",
diff --git a/dashboard/src/i18n/locales/tr.json b/dashboard/src/i18n/locales/tr.json
index 86293c4f7..14400047a 100644
--- a/dashboard/src/i18n/locales/tr.json
+++ b/dashboard/src/i18n/locales/tr.json
@@ -384,6 +384,7 @@
"phoneLabel": "Telefon Numarası",
"phonePlaceholder": "ör. 905XXXXXXXXX",
"phoneHint": "Uluslararası formatta (+, boşluk veya tire olmadan) yalnızca rakamlar (ülke kodu + numara).",
+ "relinkWarning": "whatsapp-web.js motorunda, halihazırda bağlı bir oturumu olan bir numara için kod istemek WhatsApp'ın o cihazın bağlantısını kesmesine yol açabilir. O oturumun açık kalması gerekiyorsa QR sekmesini kullanın.",
"invalidPhone": "Geçerli bir telefon numarası girin: 6–15 basamak, başta ülke kodu, sembolsüz.",
"generateButton": "Eşleme Kodu Oluştur",
"generating": "Eşleme kodu oluşturuluyor...",
diff --git a/dashboard/src/i18n/locales/zh-CN.json b/dashboard/src/i18n/locales/zh-CN.json
index 502a38950..356e99873 100644
--- a/dashboard/src/i18n/locales/zh-CN.json
+++ b/dashboard/src/i18n/locales/zh-CN.json
@@ -379,6 +379,7 @@
"phoneLabel": "电话号码",
"phonePlaceholder": "例如:919876543210",
"phoneHint": "仅填数字(不含 +、空格或连字符),使用国际格式(国家/地区代码 + 号码)。",
+ "relinkWarning": "在 whatsapp-web.js 引擎上,为已经有关联会话的号码请求配对码,可能会导致 WhatsApp 解除该设备的关联。如果该会话必须保持运行,请改用二维码标签页。",
"invalidPhone": "请输入有效的电话号码:6–15 位数字,国家/地区代码在前,不含任何符号。",
"generateButton": "生成配对码",
"generating": "正在生成配对码...",
diff --git a/dashboard/src/i18n/locales/zh-HK.json b/dashboard/src/i18n/locales/zh-HK.json
index 66b31b4d1..844f54c9c 100644
--- a/dashboard/src/i18n/locales/zh-HK.json
+++ b/dashboard/src/i18n/locales/zh-HK.json
@@ -379,6 +379,7 @@
"phoneLabel": "電話號碼",
"phonePlaceholder": "例如:919876543210",
"phoneHint": "只可輸入數字(不可有 +、空格或連字號),須為國際格式(國家代碼 + 號碼)。",
+ "relinkWarning": "在 whatsapp-web.js 引擎上,為已經有連結工作階段的號碼申請配對碼,可能會令 WhatsApp 解除該裝置的連結。如果該工作階段必須維持運作,請改用 QR 碼分頁。",
"invalidPhone": "請輸入有效的電話號碼:6 至 15 位數字,國家代碼在前,不可有符號。",
"generateButton": "產生配對碼",
"generating": "正在產生配對碼...",
diff --git a/dashboard/src/pages/Sessions.css b/dashboard/src/pages/Sessions.css
index 21822f19a..1b1e58574 100644
--- a/dashboard/src/pages/Sessions.css
+++ b/dashboard/src/pages/Sessions.css
@@ -745,6 +745,16 @@
background: rgb(239 68 68 / 0.12);
}
+.sessions-page .pairing-warning {
+ margin-bottom: 1rem;
+ padding: 0.75rem;
+ border-radius: 8px;
+ font-size: 0.8125rem;
+ text-align: start;
+ color: var(--warning-text);
+ background: rgb(245 158 11 / 0.12);
+}
+
.sessions-page .pairing-form {
text-align: start;
}
diff --git a/dashboard/src/pages/Sessions.test.ts b/dashboard/src/pages/Sessions.test.ts
index 31d844542..4185ffc35 100644
--- a/dashboard/src/pages/Sessions.test.ts
+++ b/dashboard/src/pages/Sessions.test.ts
@@ -454,6 +454,26 @@ test('a typed pairing phone number survives toggling to the QR tab and back', as
);
});
+// Nothing server-side refuses a pairing code for a number linked elsewhere, so the panel has to say
+// what it can cost before the operator types one.
+test('the phone pairing tab warns that a code can unlink an existing session', async () => {
+ const { screen, fireEvent, within } = rtl;
+ resetFetchCalls();
+ renderSessions();
+
+ await screen.findByText('new-device');
+ const qrCard = screen.getByText('new-device').closest('.session-card') as HTMLElement;
+ fireEvent.click(within(qrCard).getByRole('button', { name: 'Show QR' }));
+ await screen.findByAltText('QR');
+
+ fireEvent.click(screen.getByRole('tab', { name: 'Link with Phone Number' }));
+
+ assert.ok(
+ screen.getByText(/can make WhatsApp unlink that device/i),
+ 'the phone pairing tab offered a code with no warning',
+ );
+});
+
test('stopping a session dismisses its own open QR modal', async () => {
const { screen, fireEvent, within, waitFor } = rtl;
resetFetchCalls();
diff --git a/dashboard/src/pages/Sessions.tsx b/dashboard/src/pages/Sessions.tsx
index 6d604f3aa..30700ec96 100644
--- a/dashboard/src/pages/Sessions.tsx
+++ b/dashboard/src/pages/Sessions.tsx
@@ -770,6 +770,11 @@ export function Sessions() {
// Pairing Code Content
<div className="pairing-container" role="tabpanel">
{pairingError && <div className="pairing-error">{pairingError}</div>}
+ {/* The guards behind this button check the session's state, never the number: a code
+ requested for a number linked elsewhere has been seen to unlink that device on the
+ whatsapp-web.js engine. Shown on both engines, since the page cannot tell which one
+ a session runs without another round-trip, and the copy names the engine. */}
+ <div className="pairing-warning">{t('sessions.pairing.relinkWarning')}</div>
{!pairingCode ? (
<div className="pairing-form">