Skip to content

Commit

Permalink
fix: user creation using ADMIN_* variables (#30015)
Browse files Browse the repository at this point in the history
  • Loading branch information
debdutdeb committed Aug 8, 2023
1 parent 2d372dc commit b747f3d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/swift-birds-build.md
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

Fixed unable to create admin user using ADMIN\_\* environment variables
6 changes: 3 additions & 3 deletions apps/meteor/server/startup/initialData.js
Expand Up @@ -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'));
}
Expand Down

0 comments on commit b747f3d

Please sign in to comment.