mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-29 18:13:47 +00:00
chore(topup): harden direct-open guard and admin toggle defenses
Post-review nits: * AdminPaymentMethodEdit.tsx: `config.open_url_direct ?? false` when seeding state — defends against stale backend rendering (e.g. cache invalidation race before migration applies) * Same file: aria-label now uses the localized `admin.paymentMethods.openUrlDirect` translation key instead of hardcoded English * TopUpAmount.tsx: case-insensitive guard for Telegram deep-link URLs — `https://t.me/`, `http://t.me/`, and `tg://` all match regardless of provider casing quirks. Lowercase normalization done once before the comparisons.
This commit is contained in:
@@ -279,7 +279,14 @@ export default function TopUpAmount() {
|
||||
// handler (openInvoice / openTelegramLink в setPaymentUrl-ветке).
|
||||
// Stars уже отбит раньше через starsPaymentMutation, здесь — защита
|
||||
// на случай CryptoBot и других Telegram-deep-link провайдеров.
|
||||
if (method?.open_url_direct && !redirectUrl.startsWith('https://t.me/')) {
|
||||
// toLowerCase для устойчивости к редким провайдерам, которые могут вернуть
|
||||
// URL в нестандартном регистре. Также покрываем tg:// scheme на всякий случай.
|
||||
const lowerUrl = redirectUrl.toLowerCase();
|
||||
const isTelegramDeepLink =
|
||||
lowerUrl.startsWith('https://t.me/') ||
|
||||
lowerUrl.startsWith('http://t.me/') ||
|
||||
lowerUrl.startsWith('tg://');
|
||||
if (method?.open_url_direct && !isTelegramDeepLink) {
|
||||
window.location.href = redirectUrl;
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user