This commit is contained in:
Karol Wypchlo 2021-02-18 10:01:38 +01:00
parent 2764e11a85
commit 729accfa4d
1 changed files with 83 additions and 89 deletions

View File

@ -22,29 +22,19 @@ export async function getServerSideProps(context) {
}
try {
// console.log("headers", context.req.headers);
const { data: session, headers } = await kratos.whoami(
context.req.headers.cookie,
context.req.headers.authorization
);
console.log("session", JSON.stringify(session));
console.log("headers", JSON.stringify(headers));
const { status, data } = await kratos.getSelfServiceSettingsFlow(flow, {
headers: { cookie: context.req.headers.cookie },
});
console.log("status", status);
console.log("data", data);
if (status === 200) return { props: { flow: data } };
throw new Error(`Failed to retrieve flow ${flow} with code ${status}`);
} catch (error) {
return {
props: { error },
// redirect: {
// permanent: false,
// destination: `${config.kratos.browser}/self-service/settings/browser`,
// },
redirect: {
permanent: false,
destination: `${config.kratos.browser}/self-service/settings/browser`,
},
};
}
}
@ -60,17 +50,21 @@ export async function getServerSideProps(context) {
// },
// };
export default function Settings({ flow, error }) {
console.log("flow", flow);
console.log("error", error);
export default function Settings({ flow }) {
return null;
// const fields = flow.methods.link.config.fields
// const passwordFields = flow.methods.password.config.fields
// .map((field) => ({
// ...field,
// ...fieldProps[field.name],
// }))
// .sort((a, b) => (a.position < b.position ? -1 : 1));
// const profileFields = flow.methods.profile.config.fields
// .map((field) => ({
// ...field,
// ...fieldProps[field.name],
// }))
// .sort((a, b) => (a.position < b.position ? -1 : 1));
// return (
// <div className="min-h-screen bg-gray-50 flex flex-col justify-center py-12 sm:px-6 lg:px-8">
// <div className="sm:mx-auto sm:w-full sm:max-w-md">
@ -99,7 +93,7 @@ export default function Settings({ flow, error }) {
// <div className="mt-8 sm:mx-auto sm:w-full sm:max-w-md">
// <div className="bg-white py-8 px-4 shadow sm:rounded-lg sm:px-10">
// <form className="space-y-6" action={flow.methods.link.config.action} method={flow.methods.link.config.method}>
// {fields.map((field) => (
// {passwordFields.map((field) => (
// <div key={field.name}>
// {field.type !== "hidden" && (
// <label htmlFor={field.name} className="block text-sm font-medium text-gray-700 mb-1">
@ -139,5 +133,5 @@ export default function Settings({ flow, error }) {
// </div>
// </div>
// </div>
// );
);
}