S
S
Sasha Yashchuk2019-04-15 20:34:22
JavaScript
Sasha Yashchuk, 2019-04-15 20:34:22

How to properly save an avatar?

I am writing a chat application on KOA, Socket.IO, Mongoose, I need to implement the functionality of saving avatars for users. The system is arranged as follows: there is a login page that works on passport-local, if the user is logged in, I create a JWT, which is stored in LocalStorage, for authorization in the chat using socketIO-JWT. implemented the functionality of loading images using multer, organized the user model in monguz. And now my form sends a file to the address '/ava', the handler of which should save the file name to the user model, but I don't understand how to implement this without using sessions?5cb4c08b437f4284310176.jpeg5cb4c091e718d374296173.jpeg5cb4c0987cb4a775563004.jpeg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kirill Kudryavtsev, 2019-04-16
@Deissh

Use jwt to authenticate the user, write a middleware to validate it and get the user model.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question