From b71d751243071a878f554233dcd6ac4451af8516 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 21 May 2021 14:56:06 +0100 Subject: [PATCH] Making sure roles object is always present, issue #1529. --- packages/worker/src/api/controllers/admin/users.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/worker/src/api/controllers/admin/users.js b/packages/worker/src/api/controllers/admin/users.js index d7b198dfdb..e1aa8c1150 100644 --- a/packages/worker/src/api/controllers/admin/users.js +++ b/packages/worker/src/api/controllers/admin/users.js @@ -42,6 +42,10 @@ exports.save = async ctx => { _id: _id || generateGlobalUserID(), password: hashedPassword, } + // make sure the roles object is always present + if (!user.roles) { + user.roles = {} + } // add the active status to a user if its not provided if (user.status == null) { user.status = UserStatus.ACTIVE