Recently I was working on a Nuxt.js app and had to add authentication to it. First thing I thought was to use vuex to store two fields in a state...
For further actions, you may consider blocking this person and/or reporting abuse
I appreciate this post but you have not shown anything about what you have done on the server side
how can i save user to database(mongodb). Can we save the callback/ response from google (user/profile ) to database while adding to vuex store. If yes then how ? I had done some (hack) approch now i am saving user data to db after the user/ profile save to vuex store or store is set to user but i need to save callback directly from google or better approch
I am working on my own project i dont want to save users password in my db just want to implement google/facebook login without local auth. But i need user email (uniqueid) to save other data for reference later
What's happening on your API end points? Are you returning a token or something?
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
Good article, thanks. But what should i fix with cookie approach if i redirect always to login page if i refresh the page?
Other words if i refresh - i get loggedIn false for some seconds
i can't preserve my auth sate. everything is cleared when i refresh
Nice article but there is no data persistence
hello, thanks for the tutorial, very good ... you will have an example of this tutorial using auth token from spring security please!
I can't preserve my auth sate. everything is cleared when I refresh
I followed the same method but my auth state still goes to null on page refresh!
What could be the issue?
Solved it using vuex-persist lugin!