Skip to content

Commit

Permalink
fix: decode the accessTokenValue
Browse files Browse the repository at this point in the history
  • Loading branch information
peterphanouvong committed Dec 6, 2023
1 parent 72b380c commit b8d1216
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/authMiddleware/authMiddleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,18 @@ const handleMiddleware = async (req, options, onSuccess) => {
config.redirectURL
)
);
response.headers.set('x-hello-from-middleware2', 'hello');
return response;
}

const accessTokenValue = JSON.parse(
req.cookies.get('access_token_payload').value
);
const accessTokenValue = jwt_decode(req.cookies.get('access_token').value);

const isAuthorized =
options?.isAuthorized({req, token: accessTokenValue}) ??
isTokenValid(kindeToken.value);

if (isAuthorized && onSuccess) {
return await onSuccess({
token: JSON.parse(req.cookies.get('access_token_payload').value),
token: accessTokenValue,
user: JSON.parse(req.cookies.get('user').value)
});
}
Expand Down

0 comments on commit b8d1216

Please sign in to comment.