From 2cf82c657725d10021673c5e236644d720042a4d Mon Sep 17 00:00:00 2001 From: Kevin Aleman Date: Wed, 6 Sep 2023 10:58:09 -0600 Subject: [PATCH] roles --- .../app/authentication/server/startup/index.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/apps/meteor/app/authentication/server/startup/index.js b/apps/meteor/app/authentication/server/startup/index.js index 624368f1629ba..cc541554e8142 100644 --- a/apps/meteor/app/authentication/server/startup/index.js +++ b/apps/meteor/app/authentication/server/startup/index.js @@ -263,10 +263,14 @@ Accounts.onCreateUser(function (...args) { const { insertUserDoc } = Accounts; const insertUserDocAsync = async function (options, user) { - const globalRoles = []; + let globalRoles = new Set(); + + if (Match.test(options.globalRoles, [String]) && options.globalRoles.length > 0) { + options.globalRoles.map((role) => globalRoles.add(role)); + } if (Match.test(user.globalRoles, [String]) && user.globalRoles.length > 0) { - globalRoles.push(...user.globalRoles); + user.globalRoles.map((role) => globalRoles.add(role)); } delete user.globalRoles; @@ -275,10 +279,12 @@ const insertUserDocAsync = async function (options, user) { const defaultAuthServiceRoles = parseCSV(settings.get('Accounts_Registration_AuthenticationServices_Default_Roles') || ''); if (defaultAuthServiceRoles.length > 0) { - globalRoles.push(...defaultAuthServiceRoles); + defaultAuthServiceRoles.map((role) => globalRoles.add(role)); } } + globalRoles = [...globalRoles]; + const roles = getNewUserRoles(globalRoles); if (!user.type) {