Comments (10)
Your missing the isAuthenticated function that need to be added for each call to our API
From the tutorial " The last piece is to update our server.js file to include the passport package, initialize it with our express app, and call the isAuthenticated function for each call to our API. Open up server.js and update it as follows."
from beerlocker.
Hi Calvin,
the error indicates, that the authorization was not done correctly. Typically the req.user is set during the auth process.
May be just the authorization when you try to post the data is missing ?
Christoph
from beerlocker.
@TheFive i get the same error
from beerlocker.
wich beerlocker server are you working with 1,2,3...
from beerlocker.
@TheFive 3.2
from beerlocker.
you should add more information, when the error occurs (which version, which step in the blog you are evaluating).
Just a hint, where you can search. In the auth file, the user is taken from the database:
https://github.com/scottksmith95/beerlocker/tree/master/beerlocker-3.2/controllers
The function User.findOne retrieves the users from the database.
just add a console.log(user) in line 10, and you can see, what the result is.
(i assume, there is no user, so req.user is NULL at the stage, where the error occurs)
from beerlocker.
Thats typically, how i learn, put as much console.log in the source as you need to understand, what is going on.
from beerlocker.
@TheFive Ok. I put one user, and i can get them when i GET /api/users
[
{
"_id": "59166bf3d4de2b11707adbd8",
"username": "luiz",
"password": "$2a$05$JoE8wWw1uZ5eAC8w26PYzudMmRdj8.G3sAnU7fU5sHKsNe613GEta",
"__v": 0
}
]
When i can GET /api/beers, catch that error above. I don't understand how i can use that authentication.
from beerlocker.
Thanks @TheFive for the head-up
from beerlocker.
I get this error at frontend. It causes due to, it is not executing state means isAuthenticated
unlike this const { user, token } = isAuthenticated();
just add 'isAuthenticated()' in event like submit, It works !!
For backend all private or protected routes must include isSignedIn, isAuthenticated, or specific user group auth, middleware must include
from beerlocker.
Related Issues (6)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from beerlocker.