Where is the user object coming from?
See original GitHub issueHey guys, I’m currently studying nodejs, and this boilerplate is helping me a great deal. But I got stuck in one thing. See the code below to update an user
function update(req, res, next) {
const user = req.user;
user.username = req.body.username;
user.mobileNumber = req.body.mobileNumber;
user.save()
.then(savedUser => res.json(savedUser))
.catch(e => next(e));
}
Is the client supposed to send the entire user in the request? If not, how is the user embedded in the request?
Issue Analytics
- State:
- Created 5 years ago
- Comments:6
Top Results From Across the Web
Active Directory User Object: An Introduction
From the list of objects that appear in the menu, select User. An object creation wizard will appear.
Read more >User | Object Reference for the Salesforce Platform
Forecast managers see forecast rollups from users below them in the forecast hierarchy. FullPhotoUrl. Type: url; Properties: Filter, Nillable, Sort; Description ...
Read more >User Object - BidSwitch RTB Protocols
Each data object represents a different data source, for more information, see the Data Object section. For more information, see the User Ext...
Read more >How to get the current logged in user object from spring ...
Returns the current user object. This can be User , UserDetails or your custom user object. You will need to cast the return...
Read more >Document which properties are available in user objects.
Link new group page from relevant places, e.g. global $user doc (this might happen via an @ingroup tag, if those also apply to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
First check if the route that your update function is tied to is protected with JWT. If yes then you will get req.user automatically if client (Postman) sends requests with valid Authorization token (you get this token from auth endpoint)
Usually this req.user object is for checking JWT decoded info.
I think you are confusing it with user records stored in the database.
few.user is not what you want. It is an object which contains information that was encoded in JWT and got decided after successfull JWT validation.
Client should send user information in req.body And you should: