refs #5468 feat: modificalos acl de VnUser
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
3b7b31deb1
commit
aea39dd0b7
|
@ -0,0 +1,72 @@
|
|||
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 {
|
||||
if (!args.active) args.active = false;
|
||||
|
||||
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;
|
||||
}
|
||||
};
|
||||
};
|
|
@ -10,6 +10,9 @@ 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';
|
||||
|
||||
// Validations
|
||||
|
||||
|
|
|
@ -6,4 +6,5 @@ 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', 'preview', '*', 'ALLOW', 'ROLE', 'employee'),
|
||||
('VnUser', 'createUser', 'WRITE', 'ALLOW', 'ROLE', 'itManagement');
|
|
@ -1,6 +1,6 @@
|
|||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
url="VnUsers"
|
||||
url="VnUsers/createUser"
|
||||
data="$ctrl.user"
|
||||
insert-mode="true"
|
||||
form="form">
|
||||
|
@ -12,18 +12,18 @@
|
|||
<vn-card class="vn-pa-lg">
|
||||
<vn-vertical>
|
||||
<vn-textfield
|
||||
label="Name"
|
||||
label="Name"
|
||||
ng-model="$ctrl.user.name"
|
||||
rule="VnUser"
|
||||
vn-focus>
|
||||
</vn-textfield>
|
||||
<vn-textfield
|
||||
label="Nickname"
|
||||
label="Nickname"
|
||||
ng-model="$ctrl.user.nickname"
|
||||
rule="VnUser">
|
||||
</vn-textfield>
|
||||
<vn-textfield
|
||||
label="Email"
|
||||
label="Email"
|
||||
ng-model="$ctrl.user.email"
|
||||
rule="VnUser">
|
||||
</vn-textfield>
|
||||
|
@ -39,7 +39,7 @@
|
|||
type="password">
|
||||
</vn-textfield>
|
||||
<vn-check
|
||||
label="Active"
|
||||
label="Active"
|
||||
ng-model="$ctrl.user.active">
|
||||
</vn-check>
|
||||
</vn-vertical>
|
||||
|
|
|
@ -14,11 +14,11 @@
|
|||
<vn-item-section>
|
||||
<h6>{{::user.nickname}}</h6>
|
||||
<vn-label-value
|
||||
label="Id"
|
||||
label="Id"
|
||||
value="{{::user.id}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value
|
||||
label="User"
|
||||
label="User"
|
||||
value="{{::user.name}}">
|
||||
</vn-label-value>
|
||||
</vn-item-section>
|
||||
|
@ -36,12 +36,12 @@
|
|||
<vn-popup vn-id="summary">
|
||||
<vn-user-summary user="$ctrl.selectedUser"></vn-user-summary>
|
||||
</vn-popup>
|
||||
<a
|
||||
<a
|
||||
fixed-bottom-right
|
||||
ui-sref="account.create"
|
||||
vn-tooltip="New user"
|
||||
vn-bind="+"
|
||||
vn-acl="it"
|
||||
vn-acl="itManagement"
|
||||
vn-acl-action="remove">
|
||||
<vn-float-button icon="add"></vn-float-button>
|
||||
</a>
|
||||
</a>
|
||||
|
|
Loading…
Reference in New Issue