S
S
stas_mihailov2019-09-07 14:15:57
Node.js
stas_mihailov, 2019-09-07 14:15:57

One time link to node js?

Hello! There is a task to implement getting a private registration link through a telegram bot!
I did the following for testing:

bot.on('message', (msg) => {

    const chatId = msg.chat.id;
    bot.sendMessage(chatId, `http://localhost:${process.env.PORT}/signup/bot_${link}`);
// создание тестового хеша для ссылки
    const link = Math.random();
// роут для регистрации
    app.post(`/signup/bot_${link}`, () => {
        console.log('View')
    });

});

it is clear that if 2 users use the bot at the same time, the link will be available to the second one!
How to implement a one-time link for everyone who requests it from the bot?
Do I need to use sessions for this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stalker_RED, 2019-09-07
@stas_mihailov

Generate a unique link, write it to the database, delete it after use.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question