209 похожих чатов

Всем привет. В nest как я могу сделать типа такого



req.user = decodedToken

Потом получить этот юзер из объекта Request.


Для этого сделать мидлваре правильное решение или нужно какой нибудь декоратор кастомный?

16 ответов

6 просмотров

Да, миддлвары

А зачем так делать?

Элёр-Шодиёров Автор вопроса
Михаил Золотарёв
А зачем так делать?

Мне нужен юзер, а его хочу получить из токена

lutik
А как?

А как что? Какая задача то, кроме как замутировать объект request?

юзера класть через гард

Михаил Золотарёв
А как что? Какая задача то, кроме как замутировать...

Хочет на каждом роуте иметь текущего пользователя

Ruslan Ilmerainen
юзера класть через гард

Гарды созданы, что бы защищать, а не юзера класть

lutik
Гарды созданы, что бы защищать, а не юзера класть

ага, конечно. именно поэтому так даже в доке

Ruslan Ilmerainen
ага, конечно. именно поэтому так даже в доке

В доке ничего нормально не написано

lutik
В доке ничего нормально не написано

я согласен, но проблемы в том, что юзер запишется через гард, я не вижу

Ruslan Ilmerainen
я согласен, но проблемы в том, что юзер запишется ...

Ну тогда называй репозиторий контроллером

Элёр-Шодиёров Автор вопроса
Дмитрий Могилевцев
https://docs.nestjs.com/custom-decorators#param-de...

Я увидел именно там сделали декоратор юзера. Но там тупо взяли request и вернули request.user, А мне надо взять токен и декодировать, и вернуть юзера

Похожие вопросы

Обсуждают сегодня

We heading to 1.1$ 🤔?
CryptoBo$$
35
A couple thoughts from a random internet stranger: 1. If you want this project to gain traction you cannot keep being negative. If I just came here after finding out about Kd...
Eric Wild
46
Ideally, when we launch a game from a particular studio, that studio should have the right to access the uniqs from their game on our wallet. For example, if you die in a Ubis...
Lisandru
16
i justHey. Im holding kadena almost 3 years now. Its my only investment what isn't in profit. But i thought for years that its just need some more time but i haven't seen that...
Riki
7
Who understand exactly the uniqd in game ? Does it mean that transactions are auto signed inside the game without interruption? If yes , then how can ultra retrieve elements...
Zaa
15
So, did you guys catch the latest AMA with David from FunToken?
Noah Noure
15
remote nodes with vpn or tor still safe ? (or they can collect other information like amount, receiving/sending adress, .. ?)
Tchoupi
12
How Will #Monero Be Attacked? First of all I want to tell you that this is not teaching the network attackers, the central regulators. They already know how to attack the net...
Li₿ΞʁLiøη
3
Can you help a noob? I know LTC was one of the early alt coins. But what is the benefit of it today? What are its attributes? Why should I be bullish on it this bull run?
CryptoNoobian ($PEPI)
14
this makes me wonder, there are 6825 members in this group, all supposedly hardcore proponents of pirate and privacy. so which one of you was selling as soon as the price move...
Bartolomeo
1
Карта сайта