From 3d667fb1217b8cf90e64f95c20d8707c24cf773b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sascha=20K=C3=BChl?= Date: Mon, 26 May 2025 15:39:55 +0200 Subject: [PATCH] retrieve also user roles on login --- backend/controllers/auth.controller.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/backend/controllers/auth.controller.js b/backend/controllers/auth.controller.js index 19885a3..b11f73f 100644 --- a/backend/controllers/auth.controller.js +++ b/backend/controllers/auth.controller.js @@ -48,14 +48,11 @@ exports.login = async (req, res) => { const user = await User.findOne({ where: { authId: auth.id - } + }, + include: ['roles'] }); - const authorities = []; - const roles = await user.getRoles(); - for (let i = 0; i < roles.length; i++) { - authorities.push("ROLE_" + roles[i].name.toUpperCase()); - } + const authorities = user.roles.map(role => "ROLE_" + role.name.toUpperCase()); return res.status(200).send({ id: user.id,