From cf765cd8e18412a4817e4307aee25fd2a1763298 Mon Sep 17 00:00:00 2001 From: Karol Wypchlo Date: Tue, 16 Feb 2021 17:20:58 +0100 Subject: [PATCH] clean up --- packages/dashboard/src/components/Layout.js | 2 +- packages/dashboard/src/pages/api/hello.js | 41 -------------------- packages/dashboard/src/pages/api/hydrator.js | 7 ---- packages/dashboard/src/pages/auth/login.js | 2 - packages/dashboard/src/pages/recovery.js | 4 -- 5 files changed, 1 insertion(+), 55 deletions(-) delete mode 100644 packages/dashboard/src/pages/api/hello.js delete mode 100644 packages/dashboard/src/pages/api/hydrator.js diff --git a/packages/dashboard/src/components/Layout.js b/packages/dashboard/src/components/Layout.js index 72eaf702..e3f3e892 100644 --- a/packages/dashboard/src/components/Layout.js +++ b/packages/dashboard/src/components/Layout.js @@ -17,7 +17,7 @@ export default function Layout({ title, children }) { window.location = `${config.kratos.browser}/self-service/browser/flows/logout`; } catch (error) { - console.log(error); // todo: handle errors + console.log(error); // todo: handle errors with a message } }; diff --git a/packages/dashboard/src/pages/api/hello.js b/packages/dashboard/src/pages/api/hello.js deleted file mode 100644 index 8a73926a..00000000 --- a/packages/dashboard/src/pages/api/hello.js +++ /dev/null @@ -1,41 +0,0 @@ -// Next.js API route support: https://nextjs.org/docs/api-routes/introduction - -import jwt from "express-jwt"; -import jwks from "jwks-rsa"; -import config from "../../config"; - -// This middleware assumes that the app is secured using ORY Oathkeeper, in which case we -// verify the JSON Web Token issued by ORY Oathkeeper using the jwt-express middleware. - -const middleware = jwt({ - // Dynamically provide a signing key based on the kid in the header and the signing keys provided by the JWKS endpoint. - secret: jwks.expressJwtSecret({ - cache: true, - jwksRequestsPerMinute: 5, - jwksUri: config.jwksUrl, - }), - algorithms: ["RS256"], -}); - -// Helper method to wait for a middleware to execute before continuing -// And to throw an error when an error happens in a middleware -function runMiddleware(req, res, fn) { - return new Promise((resolve, reject) => { - fn(req, res, (result) => { - if (result instanceof Error) { - return reject(result); - } - - return resolve(result); - }); - }); -} - -export default async (req, res) => { - await runMiddleware(req, res, middleware); - - console.log(Object.keys(req)); - console.log(req.user); - res.statusCode = 200; - res.json({ name: "John Doe" }); -}; diff --git a/packages/dashboard/src/pages/api/hydrator.js b/packages/dashboard/src/pages/api/hydrator.js deleted file mode 100644 index a2065237..00000000 --- a/packages/dashboard/src/pages/api/hydrator.js +++ /dev/null @@ -1,7 +0,0 @@ -export default (req, res) => { - console.log("method", req.method); - console.log("body", req.body); - console.log("cookies", req.cookies); - - res.status(200).json({ name: "John Doe", extra: { foo: "bar" }, header: { foo: ["bar1", "bar2"] } }); -}; diff --git a/packages/dashboard/src/pages/auth/login.js b/packages/dashboard/src/pages/auth/login.js index d553ab40..8403bb5c 100644 --- a/packages/dashboard/src/pages/auth/login.js +++ b/packages/dashboard/src/pages/auth/login.js @@ -70,8 +70,6 @@ export default function Login({ flow }) { initialValues: fields.reduce((acc, field) => ({ ...acc, [field.name]: field.value }), {}), }); - console.log(flow); - return (
diff --git a/packages/dashboard/src/pages/recovery.js b/packages/dashboard/src/pages/recovery.js index 79d35b12..a9383ce3 100644 --- a/packages/dashboard/src/pages/recovery.js +++ b/packages/dashboard/src/pages/recovery.js @@ -24,10 +24,6 @@ export async function getServerSideProps(context) { try { const { status, data } = await kratos.getSelfServiceRecoveryFlow(flow); - console.log("================================================================"); - console.log(flow); - console.log("================================================================"); - if (status === 200) return { props: { flow: data } }; throw new Error(`Failed to retrieve flow ${flow} with code ${status}`);