|
|
|
|
@ -83,11 +83,11 @@ Accounts.insertUserDoc = _.wrap Accounts.insertUserDoc, (insertUserDoc, options, |
|
|
|
|
|
|
|
|
|
if roles.length is 0 |
|
|
|
|
# when inserting first user give them admin privileges otherwise make a regular user |
|
|
|
|
firstUser = RocketChat.models.Users.findOne({ _id: { $ne: 'rocket.cat' }}, { sort: { createdAt: 1 }}) |
|
|
|
|
if firstUser?._id is _id |
|
|
|
|
roles.push 'admin' |
|
|
|
|
else |
|
|
|
|
hasAdmin = RocketChat.models.Users.findOne({ roles: 'admin' }, {fields: {_id: 1}}) |
|
|
|
|
if hasAdmin? |
|
|
|
|
roles.push 'user' |
|
|
|
|
else |
|
|
|
|
roles.push 'admin' |
|
|
|
|
|
|
|
|
|
RocketChat.authz.addUserRoles(_id, roles) |
|
|
|
|
|
|
|
|
|
|