Skip to content

Commit

Permalink
Do not always update the role’s description and mandatory2fa
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigok committed May 4, 2020
1 parent d5a6b9f commit d630bbe
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions app/models/server/models/Roles.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,21 @@ export class Roles extends Base {
}

createOrUpdate(name, scope = 'Users', description = '', protectedRole = true, mandatory2fa = false) {
const updateData = {
const queryData = {
name,
scope,
description,
protected: protectedRole,
};

const updateData = {
...queryData,
description,
mandatory2fa,
};

const exists = this.findOne({
_id: name,
...updateData,
...queryData,
}, { fields: { _id: 1 } });

if (exists) {
Expand Down

0 comments on commit d630bbe

Please sign in to comment.