update WorkerBasicData layout
This commit is contained in:
parent
6edbada581
commit
f0eeb2e28b
|
@ -61,6 +61,9 @@
|
|||
},
|
||||
"twoFactor": {
|
||||
"type": "string"
|
||||
},
|
||||
"recoveryPhone": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"relations": {
|
||||
|
|
|
@ -25,9 +25,9 @@ module.exports = Self => {
|
|||
message: 'This locker has already been assigned'
|
||||
});
|
||||
|
||||
Self.validateAsync('fi', tinIsValid, {
|
||||
message: 'Invalid TIN'
|
||||
});
|
||||
// Self.validateAsync('fi', tinIsValid, {
|
||||
// message: 'Invalid TIN'
|
||||
// });
|
||||
|
||||
async function tinIsValid(err, done) {
|
||||
const filter = {
|
||||
|
@ -41,4 +41,33 @@ module.exports = Self => {
|
|||
err();
|
||||
done();
|
||||
}
|
||||
|
||||
Self.observe('before save', async function(ctx) {
|
||||
// if (ctx.isNewInstance) return;
|
||||
// const isOwner = await checkModifyPermission(ctx);
|
||||
|
||||
// const worker = await Self.findById(ctx.currentInstance.id, {
|
||||
// include: {relation: 'user', scope: {
|
||||
// fields: ['name', 'emailVerified', 'recoveryPhone']}}
|
||||
// });
|
||||
|
||||
// || ctx.data.user.recoveryPhone !== worker.user().recoveryPhone;
|
||||
// const phoneHasChanged = !!ctx.data.user?.recoveryPhone;
|
||||
// if (!isOwner && phoneHasChanged)
|
||||
// throw new UserError('This worker cant be modified');
|
||||
|
||||
// const {models} = Self.app;
|
||||
// if (phoneHasChanged)
|
||||
// await models.VnUser.updateAll({id: ctx.currentInstance.id}, {recoveryPhone: ctx.data.user.recoveryPhone});
|
||||
// return;
|
||||
});
|
||||
async function checkModifyPermission(ctx) {
|
||||
const instanceId = ctx.currentInstance.id;
|
||||
const userId = ctx.options.accessToken.userId;
|
||||
try {
|
||||
return (instanceId == userId);
|
||||
} catch (error) {
|
||||
throw new UserError(error);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -75,6 +75,12 @@
|
|||
ng-model="$ctrl.worker.SSN"
|
||||
rule>
|
||||
</vn-textfield>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
label="Recovery phone"
|
||||
ng-model="$ctrl.worker.user.recoveryPhone"
|
||||
>
|
||||
</vn-textfield>
|
||||
<vn-input-number
|
||||
min="0"
|
||||
label="Locker"
|
||||
|
|
|
@ -5,5 +5,6 @@ SSN: NSS
|
|||
Married: Casado/a
|
||||
Single: Soltero/a
|
||||
Business phone: Teléfono de empresa
|
||||
Recovery phone: Teléfono de recuperación de cuenta
|
||||
Mobile extension: Extensión móvil
|
||||
Locker: Taquilla
|
||||
|
|
|
@ -8,7 +8,7 @@ class Controller extends ModuleCard {
|
|||
{
|
||||
relation: 'user',
|
||||
scope: {
|
||||
fields: ['name', 'emailVerified'],
|
||||
fields: ['name', 'emailVerified', 'recoveryPhone'],
|
||||
include: {
|
||||
relation: 'emailUser',
|
||||
scope: {
|
||||
|
|
Loading…
Reference in New Issue