Skip to content

Commit

Permalink
fix: SAML full name update is not mirrored in DMs (#29838)
Browse files Browse the repository at this point in the history
  • Loading branch information
matheusbsilva137 committed Aug 3, 2023
1 parent 5cee214 commit 5e89694
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/honest-numbers-compete.md
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Fixes SAML full name updates not being mirrored to DM rooms.
9 changes: 5 additions & 4 deletions apps/meteor/app/meteor-accounts-saml/server/lib/SAML.ts
Expand Up @@ -123,6 +123,7 @@ export class SAML {
}));

let { username } = userObject;
const { fullName } = userObject;

const active = !settings.get('Accounts_ManuallyApproveNewUsers');

Expand All @@ -131,7 +132,7 @@ export class SAML {
const roles = userObject.roles?.length ? userObject.roles : ensureArray<string>(defaultUserRole.split(','));

const newUser: Record<string, any> = {
name: userObject.fullName,
name: fullName,
active,
globalRoles: roles,
emails,
Expand Down Expand Up @@ -199,7 +200,7 @@ export class SAML {

// Overwrite fullname if needed
if (nameOverwrite === true) {
updateData.name = userObject.fullName;
updateData.name = fullName;
}

// When updating an user, we only update the roles if we received them from the mapping
Expand All @@ -220,8 +221,8 @@ export class SAML {
},
);

if (username && username !== user.username) {
await saveUserIdentity({ _id: user._id, username });
if (username && fullName && (username !== user.username || fullName !== user.name)) {
await saveUserIdentity({ _id: user._id, name: fullName, username });
}

// sending token along with the userId
Expand Down

0 comments on commit 5e89694

Please sign in to comment.