A
A
Alice Smith2019-09-26 16:41:18
JavaScript
Alice Smith, 2019-09-26 16:41:18

Authorization via instagram on the spa?

Hello everyone
Explain that if on the server (without spa) when using passport.js, all the authentication logic happens there (redirects, saving the token, etc.), then on the spa, as I understand it, this will not work
and all this will have to be done from the client.
I think that you can somehow do it through the server, but it will not be convenient and probably pointless

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Antowa Kartowa, 2019-09-27
@AliceSmith

SPA is the client. Are you using Passport.js on the server? Through it (server) it is best to authorize and produce and, as a result, make an entry in the session table. The entry stores the token you generated, the user ID, and the date the entry was created/updated. And as a response, you give this token to SPA. On the SPA, the token is stored and added to all requests to the server. So, with each request, the server checks whether there is such a token in the session table and, if so, updates the recording time and returns the data according to the request. In mongo, you can set a lifetime for certain records, for example, 2 hours, which will be counted from the time specified in the record. If requests come regularly, then the time is updated and the session lives. If, for example, 2 hours have passed since the last activity, then the record is automatically deleted and the next time the user will need to log in again. I hope some of this is clear and this is the answer to your question.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question