I've made 2 api endpoints on my server localhost:8080 for login and profile.
On login endpoint: if user credentials is valid, set cookie 'myauth' with some unique value (token), and save this token for user in DB.
On profile endpoint: if cookie 'myauth' set and user found by token, return json with it's profile info, for example:
{
"id: 1,
"name": "Jon Snow",
"email": "jon.snow@asoiaf.com"
}
else return 401 status code with empty response.
After this manipulating my nuxt app start to login users. I've used auth middleware in nuxt config for all routings. I've used Lumen framework for api server
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Need to include some sample code to show how to implement the server-side of the Auth API.
I've made 2 api endpoints on my server localhost:8080 for login and profile.
On login endpoint: if user credentials is valid, set cookie 'myauth' with some unique value (token), and save this token for user in DB.
On profile endpoint: if cookie 'myauth' set and user found by token, return json with it's profile info, for example:
{
"id: 1,
"name": "Jon Snow",
"email": "jon.snow@asoiaf.com"
}
else return 401 status code with empty response.
After this manipulating my nuxt app start to login users. I've used auth middleware in nuxt config for all routings. I've used Lumen framework for api server