feat(auth): support bot-managed messenger login flow

This commit is contained in:
Ruslan Bakiev
2026-04-03 16:55:14 +07:00
parent f8b470f77d
commit c7908041ba

View File

@@ -90,6 +90,7 @@ app.post('/bot/messenger-login', async (req, res) => {
const userId = String(req.body?.userId || '').trim();
const email = String(req.body?.email || '').trim().toLowerCase();
const channelId = String(req.body?.channelId || '').trim();
const skipDispatch = req.body?.skipDispatch === true;
if (!channelId || (!userId && !email)) {
res.status(400).json({ error: 'channelId and (userId or email) are required.' });
return;
@@ -140,6 +141,7 @@ app.post('/bot/messenger-login', async (req, res) => {
).replace(/\/$/, '');
const loginUrl = `${frontendUrl}/login?login_token=${encodeURIComponent(login.loginToken)}`;
if (!skipDispatch) {
const dispatch = await sendMessengerMessage({
type: channel,
channelId,
@@ -152,6 +154,7 @@ app.post('/bot/messenger-login', async (req, res) => {
res.status(502).json({ error: dispatch.detail });
return;
}
}
res.json({
ok: true,