fix: CAS user merge not working (#32444)

pull/31750/head^2
Pierre Lehnen 2 years ago committed by GitHub
parent fa55c49a49
commit 760ab4be21
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 5
      .changeset/cuddly-owls-join.md
  2. 2
      apps/meteor/server/lib/cas/findExistingCASUser.ts

@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---
Fixed an issue that prevented CAS users from being merged with existing user data on login

@ -18,7 +18,7 @@ export const findExistingCASUser = async (username: string): Promise<IUser | und
// It'll also allow non-CAS users to switch to CAS based login
// #TODO: Remove regex based search
const regex = new RegExp(`^${username}$`, 'i');
const user = await Users.findOne({ regex });
const user = await Users.findOne({ username: regex });
if (user) {
// Update the user's external_id to reflect this new username.
await Users.updateOne({ _id: user._id }, { $set: { 'services.cas.external_id': username } });

Loading…
Cancel
Save