Making sure roles object is always present, issue #1529.

This commit is contained in:
mike12345567 2021-05-21 14:56:06 +01:00
parent 095e513f9f
commit a6e196a351
1 changed files with 4 additions and 0 deletions

View File

@ -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