M
M
mr jeery2019-03-25 17:29:01
Redis
mr jeery, 2019-03-25 17:29:01

How to remove key-values ​​from redis by value?

I set the key-value like this:

const token = randtoken.uid(256);
redis.set(token, email, 'EX', 60 * 60 * 24);

                const link = `${url}/auth/confirm/${token}`;


                mail.send({
                    to: to,
                    from: from,
                    subject: 'Confirm email',
                    html: `<strong>${link}</strong>`,
                });

The task is that it is possible to resend the letter to confirm the account and it is necessary that when a new token is created, the token in the old letter becomes inactive.
I need to remove or blacklist tokens knowing the email.
As far as I understand, this cannot be done directly. But are there any ways?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Papa, 2019-03-26
Stifflera @PapaStifflera

Use as a key not a random token, but email.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question