diff --git a/frontend/src/login.js b/frontend/src/login.js deleted file mode 100644 index d944ad7..0000000 --- a/frontend/src/login.js +++ /dev/null @@ -1,34 +0,0 @@ -import { createFlowForm, getFlowInfo, initFlow, whoami } from "./utils.js"; -import { kratosHost } from "./config.js"; - -async function createForm(flowId) { - console.log("Login Flow ID", flowId); - - var flowInfo; - - if (!flowId) { - flowInfo = await initFlow("login"); - - window.location.href = `${kratosHost}/self-service/login/browser`; - } - - if (!flowId && (await whoami()).status == 200) { - window.location.href = "/"; - } - - flowInfo = await getFlowInfo("login", flowId); - - if (flowInfo.status != 200) { - return await createForm(); - } - - var loginJson = await flowInfo.json(); - - console.log(loginJson); - - var form = createFlowForm(loginJson, "Log in"); - - return form; -} - -export default createForm; diff --git a/frontend/src/logout.js b/frontend/src/logout.js index b6ce209..74f8e9e 100644 --- a/frontend/src/logout.js +++ b/frontend/src/logout.js @@ -1,4 +1,4 @@ -import { createFlowForm, getFlowInfo, initFlow, whoami } from "./utils.js"; +import { initFlow } from "./utils.js"; async function createForm() { var flowInfo; diff --git a/frontend/src/recovery.js b/frontend/src/recovery.js deleted file mode 100644 index 12a2f53..0000000 --- a/frontend/src/recovery.js +++ /dev/null @@ -1,32 +0,0 @@ -import { createFlowForm, getFlowInfo, initFlow, whoami } from "./utils.js"; - -async function createForm(flowId) { - console.log("Recovery Flow ID", flowId); - var flowInfo; - - if (!flowId) { - flowInfo = await initFlow("recovery"); - - flowId = new URL(flowInfo.url).searchParams.get("flow"); - } - - if (!flowId && (await whoami()).status == 200) { - window.location.href = "/"; - } - - flowInfo = await getFlowInfo("recovery", flowId); - - if (flowInfo.status != 200) { - return await createForm(); - } - - var recoveryJson = await flowInfo.json(); - - console.log(recoveryJson); - - var form = createFlowForm(recoveryJson); - - return form; -} - -export default createForm; diff --git a/frontend/src/register.js b/frontend/src/register.js deleted file mode 100644 index 5ddd8f7..0000000 --- a/frontend/src/register.js +++ /dev/null @@ -1,32 +0,0 @@ -import { createFlowForm, getFlowInfo, initFlow, whoami } from "./utils.js"; - -async function createForm(flowId) { - console.log("Registration Flow ID", flowId); - var flowInfo; - - if (!flowId) { - flowInfo = await initFlow("registration"); - - flowId = new URL(flowInfo.url).searchParams.get("flow"); - } - - if (!flowId && (await whoami()).status == 200) { - window.location.href = "/"; - } - - flowInfo = await getFlowInfo("registration", flowId); - - if (flowInfo.status != 200) { - return await createForm(); - } - - var registrationJson = await flowInfo.json(); - - console.log(registrationJson); - - var form = createFlowForm(registrationJson, "Sign Up"); - - return form; -} - -export default createForm; diff --git a/frontend/src/router.js b/frontend/src/router.js index b44ca1e..e5d712e 100644 --- a/frontend/src/router.js +++ b/frontend/src/router.js @@ -1,10 +1,6 @@ import IndexForm from "./index.js"; -import LoginForm from "./login.js"; -import RegisterForm from "./register.js"; -import VerifyForm from "./verify.js"; -import RecoveryForm from "./recovery.js"; -import SettingsForm from "./settings.js"; import LogOutForm from "./logout.js"; +import CreateForm from "./flow.js"; const Router = { init: async function init_() { @@ -40,23 +36,23 @@ const Router = { break; case route.startsWith("/login"): document.title = "Login - Developer Friendly"; - pageElement = await LoginForm(flowId); + pageElement = await CreateForm(flowId, "login"); break; case route.startsWith("/register"): document.title = "Register - Developer Friendly"; - pageElement = await RegisterForm(flowId); + pageElement = await CreateForm(flowId, "registration"); break; case route.startsWith("/verify"): document.title = "Verify - Developer Friendly"; - pageElement = await VerifyForm(flowId); + pageElement = await CreateForm(flowId, "verification"); break; case route.startsWith("/recovery"): document.title = "Recovery - Developer Friendly"; - pageElement = await RecoveryForm(flowId); + pageElement = await CreateForm(flowId, "recovery"); break; case route.startsWith("/settings"): document.title = "Settings - Developer Friendly"; - pageElement = await SettingsForm(flowId); + pageElement = await CreateForm(flowId, "settings"); break; case route.startsWith("/logout"): document.title = "Log Out - Developer Friendly"; diff --git a/frontend/src/settings.js b/frontend/src/settings.js deleted file mode 100644 index c6bed9e..0000000 --- a/frontend/src/settings.js +++ /dev/null @@ -1,32 +0,0 @@ -import { createFlowForm, getFlowInfo, initFlow, whoami } from "./utils.js"; - -async function createForm(flowId) { - console.log("Settings Flow ID", flowId); - var flowInfo; - - if (!flowId) { - flowInfo = await initFlow("settings"); - - flowId = new URL(flowInfo.url).searchParams.get("flow"); - } - - if (!flowId && (await whoami()).status == 200) { - window.location.href = "/"; - } - - flowInfo = await getFlowInfo("settings", flowId); - - if (flowInfo.status != 200) { - return await createForm(); - } - - var settingsJson = await flowInfo.json(); - - console.log(settingsJson); - - var form = createFlowForm(settingsJson); - - return form; -} - -export default createForm; diff --git a/frontend/src/verify.js b/frontend/src/verify.js deleted file mode 100644 index 5394d82..0000000 --- a/frontend/src/verify.js +++ /dev/null @@ -1,32 +0,0 @@ -import { createFlowForm, getFlowInfo, initFlow, whoami } from "./utils.js"; - -async function createForm(flowId) { - console.log("Verify Flow ID", flowId); - var flowInfo; - - if (!flowId) { - flowInfo = await initFlow("verification"); - - flowId = new URL(flowInfo.url).searchParams.get("flow"); - } - - if (!flowId && (await whoami()).status == 200) { - window.location.href = "/"; - } - - flowInfo = await getFlowInfo("verification", flowId); - - if (flowInfo.status != 200) { - return await createForm(); - } - - var verifyJson = await flowInfo.json(); - - console.log(verifyJson); - - var form = createFlowForm(verifyJson); - - return form; -} - -export default createForm;