D
D
Denis Bukreev2018-05-28 13:42:24
User identification
Denis Bukreev, 2018-05-28 13:42:24

How to remember logged in user in SPA?

In a multi-page application, we check whether the user is authorized or not directly on the server.
But what to do in the SPA application? Having logged in once, after reloading the page, the user will again be shown the login form.
A couple of thoughts that came to mind:
- when loading the application, send a request to the server for verification, but this is a long time, because more requests may be needed in parallel to receive data
- display the USER variable in the blade template in the script tag, the presence of which will show, that the user is authorized, but this is too crutch

Answer the question

In order to leave comments, you need to log in

3 answer(s)
N
Nikita Dergachov, 2018-05-28
@vanillathunder

Need to use API Authentication

G
GTRxShock, 2018-05-28
@GTRxShock

you need to separate the front from the back (you get a js application + api)
implement authorization through jwt, for example:
https://auth0.com/blog/cookies-vs-tokens-definitiv...
https://codeburst.io/api- authentication-in-laravel...
https://auth0.com/blog/vuejs2-authentication-tutorial/

W
WarriorKodeK, 2018-05-28
@WarriorKodeK

In such cases, App-Token is used , which is issued by the back. You store this token in LocalStorage and then simply check for its presence.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question