Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: afterCreateUser callback missing roles info #30305

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion apps/meteor/app/authentication/server/startup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,10 @@ const insertUserDocAsync = async function (options, user) {
globalRoles.push(...user.globalRoles);
}

if (options.roles) {
user.roles = [...new Set([...(user.roles || []), ...options.roles])];
}

delete user.globalRoles;

if (user.services && !user.services.password) {
Expand Down Expand Up @@ -324,7 +328,7 @@ const insertUserDocAsync = async function (options, user) {
await addUserRolesAsync(_id, roles);

// Make user's roles to be present on callback
user = await Users.findOneById(_id, { projection: { username: 1, type: 1 } });
user = await Users.findOneById(_id, { projection: { username: 1, type: 1, roles: 1 } });

if (user.username) {
if (options.joinDefaultChannels !== false) {
Expand Down
1 change: 1 addition & 0 deletions apps/meteor/app/lib/server/functions/saveUser.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ const saveNewUser = async function (userData, sendPassword) {
password: userData.password,
joinDefaultChannels: userData.joinDefaultChannels,
isGuest,
roles,
};
if (userData.email) {
createUser.email = userData.email;
Expand Down
Loading