diff --git a/back/methods/vn-user/createUser.js b/back/methods/vn-user/createUser.js deleted file mode 100644 index 4dac4bcef..000000000 --- a/back/methods/vn-user/createUser.js +++ /dev/null @@ -1,70 +0,0 @@ -module.exports = function(Self) { - Self.remoteMethodCtx('createUser', { - description: 'Create a user', - accessType: 'WRITE', - accepts: [{ - arg: 'name', - type: 'string', - required: true - }, - { - arg: 'nickname', - type: 'string', - required: true - }, - { - arg: 'email', - type: 'string', - required: true - }, - { - arg: 'roleFk', - type: 'number', - required: true - }, - { - arg: 'password', - type: 'string', - required: true - }, - { - arg: 'active', - type: 'boolean' - }], - returns: { - root: true, - type: 'object' - }, - http: { - verb: 'POST', - path: '/createUser' - } - }); - - Self.createUser = async(ctx, options) => { - const models = Self.app.models; - const args = ctx.args; - let tx; - const myOptions = {}; - - if (typeof options == 'object') - Object.assign(myOptions, options); - - if (!myOptions.transaction) { - tx = await Self.beginTransaction({}); - myOptions.transaction = tx; - } - - try { - delete args.ctx; // Remove unwanted properties - const newUser = await models.VnUser.create(args, myOptions); - - if (tx) await tx.commit(); - - return newUser; - } catch (e) { - if (tx) await tx.rollback(); - throw e; - } - }; -}; diff --git a/back/models/vn-user.js b/back/models/vn-user.js index 2fa040d84..978227966 100644 --- a/back/models/vn-user.js +++ b/back/models/vn-user.js @@ -10,9 +10,8 @@ module.exports = function(Self) { require('../methods/vn-user/recover-password')(Self); require('../methods/vn-user/validate-token')(Self); require('../methods/vn-user/privileges')(Self); - require('../methods/vn-user/createUser')(Self); - Self.definition.settings.acls.find(acl => acl.property == 'create').permission = 'DENY'; + Self.definition.settings.acls.find(acl => acl.property == 'create').principalId = 'itManagement'; // Validations diff --git a/back/models/vn-user.json b/back/models/vn-user.json index fb38ad27a..e0b96a39e 100644 --- a/back/models/vn-user.json +++ b/back/models/vn-user.json @@ -124,7 +124,21 @@ ], "scopes": { "preview": { - "fields": ["id", "name", "username", "roleFk", "nickname", "lang", "active", "created", "updated", "image", "hasGrant", "realm", "email"] + "fields": [ + "id", + "name", + "username", + "roleFk", + "nickname", + "lang", + "active", + "created", + "updated", + "image", + "hasGrant", + "realm", + "email" + ] } } } diff --git a/db/changes/232201/00-aclRole.sql b/db/changes/232201/00-aclRole.sql index 3e5119b06..e16f052be 100644 --- a/db/changes/232201/00-aclRole.sql +++ b/db/changes/232201/00-aclRole.sql @@ -2,5 +2,4 @@ DELETE FROM `salix`.`ACL` WHERE model = 'Role'; INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('Role', '*', 'READ', 'ALLOW', 'ROLE', 'employee'), - ('Role', '*', 'WRITE', 'ALLOW', 'ROLE', 'hr'), - ('Role', '*', 'WRITE', 'ALLOW', 'ROLE', 'marketing'); + ('Role', '*', 'WRITE', 'ALLOW', 'ROLE', 'it'); diff --git a/db/changes/232201/00-aclVnUser.sql b/db/changes/232201/00-aclVnUser.sql index 2cbadb548..1a63ed964 100644 --- a/db/changes/232201/00-aclVnUser.sql +++ b/db/changes/232201/00-aclVnUser.sql @@ -6,5 +6,4 @@ INSERT INTO `salix`.`ACL` (model, property, accessType, permission, principalTyp VALUES ('VnUser', '*', '*', 'ALLOW', 'ROLE', 'itManagement'), ('VnUser', '__get__preview', 'READ', 'ALLOW', 'ROLE', 'employee'), - ('VnUser', 'preview', '*', 'ALLOW', 'ROLE', 'employee'), - ('VnUser', 'createUser', 'WRITE', 'ALLOW', 'ROLE', 'itManagement'); + ('VnUser', 'preview', '*', 'ALLOW', 'ROLE', 'employee'); diff --git a/modules/account/front/create/index.html b/modules/account/front/create/index.html index f373cc468..acc07d346 100644 --- a/modules/account/front/create/index.html +++ b/modules/account/front/create/index.html @@ -1,6 +1,6 @@