Skip to content

Commit

Permalink
fix: correct token payload
Browse files Browse the repository at this point in the history
  • Loading branch information
supersonictw committed Oct 14, 2024
1 parent 87cdfdf commit 9e38141
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/middleware/access.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions src/routes/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -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});
},
);

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 9e38141

Please sign in to comment.