Skip to content

Commit

Permalink
error checking
Browse files Browse the repository at this point in the history
  • Loading branch information
peterphanouvong committed May 25, 2022
1 parent b78a53f commit 65e542a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion bundle.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion src/handlers/callback.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export const callback = async (req, res) => {
const data = await response.json();

// check token claims
console.log(data);
// save token
res.setHeader(
"Set-Cookie",
Expand Down
7 changes: 4 additions & 3 deletions src/handlers/me.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ var cookie = require("cookie");

export const me = async (req, res) => {
const kinde_token = cookie.parse(req.headers.cookie || "")["kinde_token"];
const token = JSON.parse(kinde_token);

if (kinde_token) {
const token = JSON.parse(kinde_token);
try {
const response = await fetch(
`https://${process.env.KINDE_DOMAIN}/oauth2/user_profile`,
Expand All @@ -15,10 +16,10 @@ export const me = async (req, res) => {
);
const data = await response.json();
res.send(data);
console.log(data);
} catch (err) {
console.log(err);
}
} else {
res.status(401).send("Unauthorized");
}
res.end();
};

0 comments on commit 65e542a

Please sign in to comment.