userModel is not extended correctly
See original GitHub issueWhen extending the user model, nested arrays are not concatenated their positions are overwritten.
ie:
var userModelConfig = {whitelist: ['1','2','3','4','5','6']}
var userModel = {whitelist: ['a','b','c']}
$.extend(true, {}, userModel, userModelConfig)
//returns
{"whitelist":["1","2","3","4","5","6"]}
and
$.extend(true, {}, userModelConfig, userModel)
"{"whitelist":["a","b","c","4","5","6"]}"
As you can see the index position of the array is overwritten rather then extend or merged.
A potential solution would be to transform the arrays into objects, extend them and transform them back.
I was going to try to fix it and submit a pull request, but i dont have the time tonight so i wanted to get this to you, maybe you have a quicker solution.
Issue Analytics
- State:
- Created 8 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
django - Extended user model not save password correctly
im trying to create a child and parent objects at the same time with same form. After migrations, i have two tables, user...
Read more >Data not saving correctly · Issue #76 · szokodiakos/typegoose
I want to save a mongoose document with a typegoose sub-document but data isn't saving correctly. Car Model does not extend Typegoose
Read more >How to Extend Django User Model
Ways to Extend the Existing User Model · Option 1: Using a Proxy Model · Option 2: Using One-To-One Link With a User...
Read more >Extending the existing User model - Using Django
Hi, now I try to extend the user model of my django app to store a pin and a balance with the useraccount...
Read more >is this a correct way to extend the user model , how to create a view ...
Here's an example: class MyUser(AbstractUser): bio = models.CharField(...) Note that date_joined is already a field on AbstractUser , you don't need 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 Free
Top 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
OK, now I understand exactly what you are saying. Currently if you want to change the
whitelist
, you have to repeat it:I’ll work on this for the next version of SuperLogin, but don’t know when I’ll get to it. If you can do I pull request with a passing test in
user.spec.js
then I would be happy to merge it.So what im trying to say is the node extend is basically a clone to jquery extend. And extend will not merge 2 arrays.
So for example, if you were to add this to the config file
You would get an error saying the username, password, and confirmPassword is required. This is because
userModel = extend(true, userModel, config.getItem('userModel'));
would return the whitelist array like thisThis is because extend will overwrite the array rather then merge them. But what you really want is a unique merge.
Hope that makes more sense.