6067-vnUser_privileges_and_verifyEmail #1764
No reviewers
Labels
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: verdnatura/salix#1764
Loading…
Reference in New Issue
No description provided.
Delete Branch "6067-vnUser_privileges_and_verifyEmail"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@ -222,0 +204,4 @@
Self.observe('after save', async ctx => {
const newEmail = ctx?.instance?.email;
const oldEmail = ctx?.hookState?.oldInstance?.email;
if (!ctx.isNewInstance && (!newEmail || !oldEmail || newEmail == oldEmail)) return;
Sobre isNewInstance.
Mirar la nota https://redmine.verdnatura.es/issues/5761#note-8
@ -0,0 +35,4 @@
Self.updateUser = async(ctx, id) => {
await Self.userSecurity(ctx, id);
const user = await Self.app.models.VnUser.findById(id,
{fields: ['id', 'name', 'nickname', 'email', 'lang', 'password']});
En lugar de hacer
findById
y luegoupdateAttributes
, utilizarupsert
.@ -0,0 +36,4 @@
await Self.userSecurity(ctx, id);
const user = await Self.app.models.VnUser.findById(id,
{fields: ['id', 'name', 'nickname', 'email', 'lang', 'password']});
await user.updateAttributes(ctx.args);
En lugar de utilizar
ctx.args
listar parámetros en la definición de la función y pasarlos todos excepto elid
.@ -216,3 +201,1 @@
// protocol: url[0],
// user: Self
// };
throw new UserError(`You don't have enough privileges`);
En lugar de lanzar
UserError
lanzarForbiddenError
.@ -222,0 +231,4 @@
type: 'email',
to: newEmail,
from: {},
redirect: `${origin}/#!/account/${ctx.instance.id}/basic-data?emailConfirmed`,
Redirigir a un (nuevo) subestado
verifyEmail
del login de Lilium donde, en función de si el usuario tiene account, mostrar "Ir a la tienda" o "Iniciar sesión".@ -0,0 +4,4 @@
('VnUser', 'mediumPrivileges', '*', 'ALLOW', 'ROLE', 'hr'),
('VnUser', 'updateUser', '*', 'ALLOW', 'ROLE', 'employee');
ALTER TABLE `account`.`user` ADD `username` varchar(30) AS (name) VIRTUAL;
Probar si la nueva columna virtual
username
es actualizable.@ -0,0 +7,4 @@
Self.observe('before delete', async ctx => {
await Self.app.models.VnUser.userSecurity(ctx, ctx.where.account);
});
};
Este código no es necesario, solo hay que verificar
userSecurity
al cambiar el correo de recuperación.@ -155,6 +155,7 @@ module.exports = Self => {
password: randomPassword.password,
email: args.email,
roleFk: workerConfig.roleFk,
isWorker: true // to verifyEmail
Aço ho he tingut que ficar pq no hi ha forma de si el crees saber que es un treballador no...
Se me ha ocurrit ficarli un paremetre mes que no es gasta per res mes, pero no me acaba la solució.
Tb se podria ficar en el ctx.options algo com isNewWorker o algo
WIP: 6067-vnUser_privileges_and_verifyEmailto 6067-vnUser_privileges_and_verifyEmailNew commits pushed, approval review dismissed automatically according to repository settings