Passwords sets NULL/empty when upserting extended User model

24 views
Skip to first unread message

Lander Vanderstraeten

unread,
Oct 11, 2017, 2:25:30 PM10/11/17
to LoopbackJS
As my title says, I have a model called Accounts, who extends the build-in User model.
But when I send a PUT request to /apiurl/Accounts to store my custom fields (eq age, birthdate, birthplace) the field passwords is set to NULL ?

How can i upsert my extended user model without setting the password blanco?

I am aware of the security when you modify the username or email that we need to create a new accessToken, but when i modify the birthplace or birthdate this is not necessary?

Thanks a bunch for your tips,

Lander

Francois Laforge

unread,
Oct 13, 2017, 10:36:48 AM10/13/17
to LoopbackJS
We have a model (Member) that inherits from the User model and we can PUT data to update name, job-title, without any problems.

Do you have any custom code that might be errasing the password?  Account.Observe() or Account.beforeRemote, etc?

Lander Vanderstraeten-Sintobin

unread,
Jan 16, 2018, 2:56:18 PM1/16/18
to LoopbackJS
Dear Francois,

Which connector do you use? MYSQL? I think the MYSQL connector is writing all the values NULL, even if they are NOT setted.

Thanks,

Lander

Op vrijdag 13 oktober 2017 16:36:48 UTC+2 schreef Francois Laforge:

Francois Laforge

unread,
Feb 16, 2018, 9:22:02 AM2/16/18
to LoopbackJS
We're using MongoDb.

I'm in the process of migrating our loopback 2 to loopback 3 and saw that all PUT commands should be changed to PATCH commands.

If you are using Loopback 3 and trying to update your member data using PUT, then all other fields will be set to null.  You need to use the PATCH command to only update the fields you are sending to the server.  

F
Reply all
Reply to author
Forward
0 new messages