diff --git a/server/methods/deleteUser.js b/server/methods/deleteUser.js index d8b0ce2e7bd32..e2c169167ff71 100644 --- a/server/methods/deleteUser.js +++ b/server/methods/deleteUser.js @@ -36,7 +36,7 @@ Meteor.methods({ const adminCount = Meteor.users.find({ roles: 'admin' }).count(); - const userIsAdmin = user.roles.indexOf('admin') > -1; + const userIsAdmin = user.roles?.indexOf('admin') > -1; if (adminCount === 1 && userIsAdmin) { throw new Meteor.Error('error-action-not-allowed', 'Leaving the app without admins is not allowed', {