Closed graupe closed 7 years ago
At first glace it looks good! Looking forward to checking out your PR in depth 😄
I think I have to reevaluate the logic... for example, the location property should not be mandatory. Right now the profiles's location will just be set to empty string, if it is not given in the payload, which is a breaking change I guess. It actually is working alright. But more by accident.
@graupe You may want to consider rewriting if it helps, but one thing that would be nice would be to actually allow the update of any field in the user hash, instead of just username, firstname, lastname, etc...
So we can do things like birthday update or location update.
I had really a lot WTF moments, since this is my first time developing for any node application. After I updated the code to support all user properties, I realized that upon creation some of these fields are actually not being initialized. Wich made me rethink the whole findUser-Method. I might have employed serveral anti-patterns, since I am new to this arcane beast of callbacks.
Please test this, if you think my changes are worth to being integrated. If not, I will find a simpler solution to add 'location' to the profile, since that was what I actually wanted to do :)
Ahh, sorry! Just noticed that I missed the admin-panel for the configuration. Will do that ASAP. Shouldn't bar you from having a look.
Sorry for the noise, I expected github to keep the history of temporarily added commits. (I am usually working with bitbucket)
Are you considering this PR? In the end, the only thing I really need to workout is the "location"-property being transfered. I will have to find some means to do it, whether it is by this PR, a smaller change set or my own fork. I had rather not publish yet another plugin with almost the same functionality.
Hi @graupe -- my main concern is that it maintains backwards compatibility with the older version, so no config changes are requires as we have clients that also use this plugin. Will take a look today.
It looks like payloadParent
is one change that would make this PR a breaking change (which is not a problem as long as it is documented)...
One could make this not breaking by checking for both payload:parent
and payloadParent
in the plugin settings. If the former is set while the latter is not, then set the latter and erase the former.
Added some migration logic for payloadParent
Well done, and thank you for the contribution 😄 Apologies for the delay.
Thanks a lot @julianlam! You are absolutely right about the configuration not being backwards compatible. Didn't think about that dilemma! On a similar matter, just looking at the code: It may be, that a fresh installation of this plugin might actually not load, since there is no secret in the database. I circumvented it by adding a default secret value in the code on first install, but I won't take the time to confirm it now.
Just tested by deleting settings:session-sharing
. The warning about a missing secret comes up and you can set one in the plugin settings, so all's well.
This was mainly motivated by the username not being stripped from special characters on profile updates. Or is there a special reason, this was not put in place?
It also adds some hopefully meaning full log messages as well as cleaner code, YMMV.