fix(auth): add pexsecBot for Telegram login on app.pezkuwichain.io

- pex.mom uses @PexMomBOT (8690398980)
- app.pezkuwichain.io uses @pexsecBot (8754021997)
- Edge function selects token based on bot_id from request
This commit is contained in:
2026-05-01 23:32:25 +03:00
parent ef6a7b2583
commit 9babb94e07
2 changed files with 8 additions and 6 deletions
+2 -2
View File
@@ -163,7 +163,7 @@ const Login: React.FC = () => {
setError('');
setLoading(true);
const BOT_ID = '8690398980';
const BOT_ID = window.location.hostname === 'pex.mom' ? '8690398980' : '8754021997';
const origin = window.location.origin;
const popup = window.open(
`https://oauth.telegram.org/auth?bot_id=${BOT_ID}&origin=${encodeURIComponent(origin)}&embed=1&request_access=write`,
@@ -196,7 +196,7 @@ const Login: React.FC = () => {
'apikey': supabaseKey,
'Authorization': `Bearer ${supabaseKey}`,
},
body: JSON.stringify(tgData),
body: JSON.stringify({ ...tgData, bot_id: BOT_ID }),
});
const json = await res.json();
@@ -42,11 +42,13 @@ Deno.serve(async (req) => {
}
try {
const botToken = Deno.env.get('TELEGRAM_BOT_TOKEN_PEZMOM')
if (!botToken) throw new Error('TELEGRAM_BOT_TOKEN_PEZMOM not configured')
const body = await req.json()
const { id, first_name, last_name, username, photo_url, auth_date, hash } = body
const { id, first_name, last_name, username, photo_url, auth_date, hash, bot_id } = body
const botToken = bot_id === '8690398980'
? Deno.env.get('TELEGRAM_BOT_TOKEN_PEZMOM')
: Deno.env.get('TELEGRAM_BOT_TOKEN_PEXSEC')
if (!botToken) throw new Error('Bot token not configured for bot_id: ' + bot_id)
if (!id || !hash || !auth_date) {
return new Response(JSON.stringify({ error: 'Missing required fields' }), {