Refactor: Implement DashboardLayout, fix mobile nav, and resolve scroll issues
This commit is contained in:
25
app/api/auth/send/route.ts
Normal file
25
app/api/auth/send/route.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { NextResponse } from 'next/server';
|
||||
import TelegramBot from 'node-telegram-bot-api';
|
||||
import { generateOTP, saveOTP } from '@/lib/otp';
|
||||
|
||||
export async function POST() {
|
||||
const token = process.env.TELEGRAM_BOT_TOKEN;
|
||||
const chatId = process.env.TELEGRAM_CHAT_ID;
|
||||
|
||||
if (!token || !chatId) {
|
||||
console.error("Telegram credentials missing");
|
||||
return NextResponse.json({ error: 'Telegram not configured' }, { status: 500 });
|
||||
}
|
||||
|
||||
const otp = generateOTP();
|
||||
saveOTP(otp);
|
||||
|
||||
const bot = new TelegramBot(token, { polling: false });
|
||||
try {
|
||||
await bot.sendMessage(chatId, `🔐 Your Login Code: ${otp}`);
|
||||
return NextResponse.json({ success: true });
|
||||
} catch (error: any) {
|
||||
console.error('Telegram Error:', error);
|
||||
return NextResponse.json({ error: 'Failed to send message: ' + error.message }, { status: 500 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user