Skip to content

Commit

Permalink
Merge pull request #1647 from RocketChat/rocket-chat-shouldnt-be-admin
Browse files Browse the repository at this point in the history
Rocket.Cat Shouldn't be Admin, allowing first users to be admins again
  • Loading branch information
graywolf336 committed Dec 12, 2015
2 parents b023db6 + cebb602 commit 199d3de
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion server/lib/accounts.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Accounts.insertUserDoc = _.wrap Accounts.insertUserDoc, (insertUserDoc) ->
_id = insertUserDoc.call(Accounts, options, user)

# when inserting first user give them admin privileges otherwise make a regular user
firstUser = RocketChat.models.Users.findOne({},{sort:{createdAt:1}})
firstUser = RocketChat.models.Users.findOne({ _id: { $ne: 'rocket.cat' }}, { sort: { createdAt: 1 }})
roleName = if firstUser?._id is _id then 'admin' else 'user'

RocketChat.authz.addUsersToRoles(_id, roleName)
Expand Down
2 changes: 1 addition & 1 deletion server/startup/initialData.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Meteor.startup ->
# Set oldest user as admin, if none exists yet
if _.isEmpty( RocketChat.authz.getUsersInRole( 'admin' ).fetch())
# get oldest user
oldestUser = RocketChat.models.Users.findOne({}, { fields: { username: 1 }, sort: {createdAt: 1}})
oldestUser = RocketChat.models.Users.findOne({ _id: { $ne: 'rocket.cat' }}, { fields: { username: 1 }, sort: {createdAt: 1}})
if oldestUser
RocketChat.authz.addUsersToRoles( oldestUser._id, 'admin')
console.log "No admins are found. Set #{oldestUser.username} as admin for being the oldest user"

0 comments on commit 199d3de

Please sign in to comment.