Merge pull request #16082 from overleaf/jel-group-sso-already-linked

[web] Fix projection when checking if user is already enrolled in SSO

GitOrigin-RevId: eebe645cba2f911783f1b2a636a4fc51a8f6107b
This commit is contained in:
Jessica Lawshe 2023-12-04 09:11:57 -06:00 committed by Copybot
parent e57806b204
commit 8a741b89f2

View file

@ -18,10 +18,7 @@ async function checkUserCanEnrollInSubscription(userId, subscription) {
throw new Errors.SAMLGroupSSOLoginIdentityNotFoundError() throw new Errors.SAMLGroupSSOLoginIdentityNotFoundError()
} }
const user = await User.findOne( const user = await User.findOne({ _id: userId }, { enrollment: 1 }).exec()
{ _id: userId },
{ projection: { enrollment: 1 } }
).exec()
const userIsEnrolled = user.enrollment?.sso?.some( const userIsEnrolled = user.enrollment?.sso?.some(
enrollment => enrollment.groupId.toString() === subscription._id.toString() enrollment => enrollment.groupId.toString() === subscription._id.toString()