From 5d4e437f8c65c54a6869e4c5d047809e33b04348 Mon Sep 17 00:00:00 2001 From: bshabib Date: Mon, 28 Feb 2022 00:49:59 +0600 Subject: [PATCH] Refactor. --- src/modules/platform/role/role.controller.js | 6 +++--- src/modules/platform/user/user.model.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/modules/platform/role/role.controller.js b/src/modules/platform/role/role.controller.js index f008f3b..cb42afb 100644 --- a/src/modules/platform/role/role.controller.js +++ b/src/modules/platform/role/role.controller.js @@ -194,12 +194,12 @@ async function updateRole(req, res) { if (title) { const slug = makeCustomSlug(title); - await role.update({ title, slug, updated_by: req.params.id }); + await role.update({ title, slug, updated_by: req.user.id }); } - if (type) await role.update({ type, updated_by: req.params.id }); + if (type) await role.update({ type, updated_by: req.user.id }); - if (description) await role.update({ description, updated_by: req.params.id }); + if (description) await role.update({ description, updated_by: req.user.id }); if (permissions) { await RolePermission.destroy({ where: { role_id: role.id }}); diff --git a/src/modules/platform/user/user.model.js b/src/modules/platform/user/user.model.js index f22e42a..a0fe86b 100644 --- a/src/modules/platform/user/user.model.js +++ b/src/modules/platform/user/user.model.js @@ -80,7 +80,7 @@ User.prototype.validPassword = function (password) { }; User.belongsTo(User, { as: 'createdByUser', foreignKey: 'created_by' }); -User.belongsTo(User, { as: 'updatedByUser', foreignKey: 'created_by' }); +User.belongsTo(User, { as: 'updatedByUser', foreignKey: 'updated_by' }); Profile.hasMany(User, { as: 'users', foreignKey: 'profile_id', constraints: false }); User.belongsTo(Profile, { as: 'profile', foreignKey: 'profile_id', constraints: false });