Skip to content

Commit

Permalink
roles
Browse files Browse the repository at this point in the history
  • Loading branch information
KevLehman committed Sep 6, 2023
1 parent d118801 commit 32e0068
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions apps/meteor/app/authentication/server/startup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down

0 comments on commit 32e0068

Please sign in to comment.