diff --git a/src/middleware/access.js b/src/middleware/access.js index 096f63d..8da1065 100644 --- a/src/middleware/access.js +++ b/src/middleware/access.js @@ -40,7 +40,7 @@ module.exports = (requiredRole) => (req, res, next) => { } // Read roles from metadata - const userRoles = req.auth.metadata?.user?.roles; + const userRoles = req.auth.metadata?.profile?.roles; const isUserRolesValid = Array.isArray(userRoles); // Check permission diff --git a/src/routes/users.js b/src/routes/users.js index 105f8e4..042ed71 100644 --- a/src/routes/users.js +++ b/src/routes/users.js @@ -52,7 +52,10 @@ const cache = useCache(); router.get("/me", middlewareAccess(null), async (req, res) => { - res.send({profile: req.auth.metadata.user}); + const { + profile, + } = req.auth.metadata; + res.send({profile}); }, ); @@ -99,7 +102,7 @@ router.put("/me", // Handle updates user.nickname = req?.body?.nickname || - req.auth.metadata.user.nickname; + req.auth.metadata.profile.nickname; // Update values const metadata = await utilUser.saveData(user);