Skip to content
This repository was archived by the owner on Dec 14, 2023. It is now read-only.

Commit d711d69

Browse files
committed
Fix issue where user updating their name was not updating their sys_name
Close CoderDojo/community-platform#1202
1 parent 3449741 commit d711d69

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

profiles.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ module.exports = function (options) {
1616

1717
var syncedFields = [
1818
'name',
19+
'firstName',
20+
'lastName',
1921
'email',
2022
'phone'
2123
];
@@ -110,7 +112,10 @@ module.exports = function (options) {
110112
if (args.user && !_.isEmpty(retProfile.email) && args.user.lmsId && args.user.email !== retProfile.email) {
111113
seneca.act({role: 'cd-users', cmd: 'update_lms_user', lmsId: args.user.lmsId, userEmail: args.user.email, profileEmail: retProfile.email});
112114
}
113-
syncUserObj(profile, function (err, res) {
115+
// save mutates the profile values, like "name" from "firstName" + "lastName" and need to be ported to the synced sys_user
116+
var syncProfile = _.omit(retProfile, immutableFields);
117+
syncProfile.user = profile.user;
118+
syncUserObj(syncProfile, function (err, res) {
114119
if (err) return done(err);
115120

116121
syncForumProfile(retProfile, function (err, res) {
@@ -251,8 +256,10 @@ module.exports = function (options) {
251256
if (err) {
252257
return done(err);
253258
}
254-
255-
syncUserObj(profile, function (err, res) {
259+
// save mutates the profile values, like "name" from "firstName" + "lastName" and need to be ported to the synced sys_user
260+
savedProfile = _.omit(savedProfile, fieldsToBeRemoved);
261+
savedProfile.user = profile.user;
262+
syncUserObj(savedProfile, function (err, res) {
256263
if (err) return done(err);
257264

258265
return done(null, profile);

0 commit comments

Comments
 (0)