From 32e0068d4264e0febb57c992e7ebbd3c32d608cc 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 624368f1629b..cc541554e814 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) {