diff --git a/.changeset/swift-birds-build.md b/.changeset/swift-birds-build.md new file mode 100644 index 0000000000000..4af3bddd875be --- /dev/null +++ b/.changeset/swift-birds-build.md @@ -0,0 +1,5 @@ +--- +'@rocket.chat/meteor': patch +--- + +Fixed unable to create admin user using ADMIN\_\* environment variables diff --git a/apps/meteor/server/startup/initialData.js b/apps/meteor/server/startup/initialData.js index e630ff89319ba..61fbdf9f3328a 100644 --- a/apps/meteor/server/startup/initialData.js +++ b/apps/meteor/server/startup/initialData.js @@ -115,11 +115,11 @@ Meteor.startup(async () => { adminUser.type = 'user'; - const id = await Users.create(adminUser); + const { insertedId: userId } = await Users.create(adminUser); - await Accounts.setPasswordAsync(id, process.env.ADMIN_PASS); + await Accounts.setPasswordAsync(userId, process.env.ADMIN_PASS); - await addUserRolesAsync(id, ['admin']); + await addUserRolesAsync(userId, ['admin']); } else { console.log(colors.red('Users with admin role already exist; Ignoring environment variables ADMIN_PASS')); }