From e5ec6cc4efa27b7b8caf11674141addd3df79c4e Mon Sep 17 00:00:00 2001 From: Lina Date: Tue, 29 Apr 2025 12:20:16 +0200 Subject: [PATCH 1/8] PR comments --- Dockerfile | 2 +- dev.Dockerfile | 2 +- pages/settings.tsx | 5 +---- pkg/ui/Messages.tsx | 3 ++- submodules/javascript-functions | 2 +- submodules/react-components | 2 +- util/helper-functions.ts | 8 ++++++++ 7 files changed, 15 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8792772..2605cc2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:14-alpine as build +FROM node:20-alpine as build WORKDIR /app COPY package*.json /app/ diff --git a/dev.Dockerfile b/dev.Dockerfile index 5cf11c6..d26268d 100644 --- a/dev.Dockerfile +++ b/dev.Dockerfile @@ -1,4 +1,4 @@ -FROM node:14-alpine +FROM node:20-alpine WORKDIR /app diff --git a/pages/settings.tsx b/pages/settings.tsx index 5b836a6..a8a179e 100644 --- a/pages/settings.tsx +++ b/pages/settings.tsx @@ -153,8 +153,7 @@ const Settings: NextPage = () => { {!isOidc ?
-

Change password

- +

{flowId ? 'Set' : 'Change'} password

{ {containsBackupCodes ? (

Manage 2FA backup recovery codes

Recovery codes can be used in panic situations where you have lost access to your 2FA device.

- { href="https://play.google.com/store/apps/details?id=com.google.android.apps.authenticator2&hl=en&gl=US" target="_blank">Android).

- { return ( - {message.text} + {displayMessage(message)} ) diff --git a/submodules/javascript-functions b/submodules/javascript-functions index 12bf29c..5a07039 160000 --- a/submodules/javascript-functions +++ b/submodules/javascript-functions @@ -1 +1 @@ -Subproject commit 12bf29c1966fe1bfeb716d4e6f4dc9112e7c1ee4 +Subproject commit 5a070394a45b5ed5a86efd0fc42370331e0ab101 diff --git a/submodules/react-components b/submodules/react-components index 7f969a7..b758303 160000 --- a/submodules/react-components +++ b/submodules/react-components @@ -1 +1 @@ -Subproject commit 7f969a7bf3d279ed656380a0b69b8a7d7f0adf09 +Subproject commit b7583037d9b1a6dfaacf28afe9ab6cd89ecc3c2d diff --git a/util/helper-functions.ts b/util/helper-functions.ts index 832b605..466d040 100644 --- a/util/helper-functions.ts +++ b/util/helper-functions.ts @@ -1,3 +1,7 @@ +const customMessageOverrides = { + 1060001: "Welcome to the app! You have successfully registered. Set your first, last name and password to continue.", +}; + export function getValueIdentifier(selectedRole: any) { let value = ''; if (selectedRole === 'engineer') { @@ -58,4 +62,8 @@ export function prepareNodes(flow: any) { } return filteredNodes; +} + +export function displayMessage(msg: any): string { + return customMessageOverrides[msg.id] || msg.text; } \ No newline at end of file From c040f1407e8ffa08a713f4f52a5d51a659b2e961 Mon Sep 17 00:00:00 2001 From: Lina Date: Fri, 2 May 2025 11:38:38 +0200 Subject: [PATCH 2/8] Disable buttons and show correct buttons based on the provider --- Dockerfile | 2 +- dev.Dockerfile | 2 +- pages/settings.tsx | 47 ++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 47 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2605cc2..7df8d3c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:20-alpine as build +FROM node:18-alpine as build WORKDIR /app COPY package*.json /app/ diff --git a/dev.Dockerfile b/dev.Dockerfile index d26268d..257cbb8 100644 --- a/dev.Dockerfile +++ b/dev.Dockerfile @@ -1,4 +1,4 @@ -FROM node:20-alpine +FROM node:18-alpine WORKDIR /app diff --git a/pages/settings.tsx b/pages/settings.tsx index a8a179e..ec9e5aa 100644 --- a/pages/settings.tsx +++ b/pages/settings.tsx @@ -26,6 +26,8 @@ const Settings: NextPage = () => { const [isOidc, setIsOidc] = useState(false); const [user, setUser] = useState(null); const [activeAdminMessages, setActiveAdminMessages] = useState([]); + const [isOidcInvitation, setIsOidcInvitation] = useState(false); + const [backButtonDisabled, setBackButtonDisabled] = useState(false); // Get ?flow=... from the URL const router = useRouter() const { flow: flowId, return_to: returnTo } = router.query @@ -104,9 +106,39 @@ const Settings: NextPage = () => { if (["microsoft", "google"].includes(initialFlow.identity.metadata_public?.registration_scope?.provider_id)) { initialFlow.ui.nodes = initialFlow.ui.nodes.filter((node: UiNode) => node.group !== "password"); setIsOidc(true); + if (initialFlow.identity.metadata_public?.registration_scope?.invitation_sso) { + setIsOidcInvitation(true); + } + const provider = initialFlow.identity.metadata_public?.registration_scope?.provider_id; + if (provider === "google") { + console.log(document.querySelector('button[value="Microsoft"]')) + document.querySelector('button[value="Microsoft"]')?.setAttribute("class", "hidden"); + } else if (provider === "microsoft") { + document.querySelector('button[value="Google"]')?.setAttribute("class", "hidden"); + } } + }, [initialFlow, changedFlow]) - }, [initialFlow]) + useEffect(() => { + if (!changedFlow || !initialFlow) return; + const firstNameButtonVal = (document.querySelector('input[name="traits.name.first"]') as HTMLInputElement)?.value; + const lastNameButtonVal = (document.querySelector('input[name="traits.name.last"]') as HTMLInputElement)?.value; + if (isOidc && isOidcInvitation) { + if (firstNameButtonVal === "" || lastNameButtonVal === "") { + setBackButtonDisabled(true); + } else { + setBackButtonDisabled(false); + } + } else { + const emailButtonVal = (document.querySelector('input[name="traits.email"]') as HTMLInputElement)?.value; + const passwordButtonVal = (document.querySelector('input[name="password"]') as HTMLInputElement)?.value; + if (firstNameButtonVal === "" || lastNameButtonVal === "" || emailButtonVal === "" || passwordButtonVal === "") { + setBackButtonDisabled(true); + } else { + setBackButtonDisabled(false); + } + } + }, [isOidc, isOidcInvitation, initialFlow, changedFlow]); const onSubmit = (values: UpdateSettingsFlowBody) => ory @@ -190,8 +222,19 @@ const Settings: NextPage = () => { />
) : (<> )} + {isOidc && isOidcInvitation ? (
+ +
) : (<> )} +
- Back +
From cd23eaf3e35bd544b94cf426275718efe4373ec4 Mon Sep 17 00:00:00 2001 From: Lina Date: Fri, 2 May 2025 11:38:56 +0200 Subject: [PATCH 3/8] remove console log --- pages/settings.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/pages/settings.tsx b/pages/settings.tsx index ec9e5aa..e32a874 100644 --- a/pages/settings.tsx +++ b/pages/settings.tsx @@ -111,7 +111,6 @@ const Settings: NextPage = () => { } const provider = initialFlow.identity.metadata_public?.registration_scope?.provider_id; if (provider === "google") { - console.log(document.querySelector('button[value="Microsoft"]')) document.querySelector('button[value="Microsoft"]')?.setAttribute("class", "hidden"); } else if (provider === "microsoft") { document.querySelector('button[value="Google"]')?.setAttribute("class", "hidden"); From 9ee74de1cf9963dc090b62b123daf9e3099f7f50 Mon Sep 17 00:00:00 2001 From: Lina Date: Mon, 5 May 2025 11:28:48 +0200 Subject: [PATCH 4/8] PR comments --- submodules/react-components | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/submodules/react-components b/submodules/react-components index b758303..52805a7 160000 --- a/submodules/react-components +++ b/submodules/react-components @@ -1 +1 @@ -Subproject commit b7583037d9b1a6dfaacf28afe9ab6cd89ecc3c2d +Subproject commit 52805a7be383d0b4e08dac697defe6b8b9ec00d0 From 57cbff588f52be6982492f89c931742d69189205 Mon Sep 17 00:00:00 2001 From: Lina Date: Mon, 5 May 2025 14:42:22 +0200 Subject: [PATCH 5/8] drone build --- submodules/react-components | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/submodules/react-components b/submodules/react-components index 52805a7..f29a797 160000 --- a/submodules/react-components +++ b/submodules/react-components @@ -1 +1 @@ -Subproject commit 52805a7be383d0b4e08dac697defe6b8b9ec00d0 +Subproject commit f29a797ab876fa443f0e90fa9dc7798e93cd397a From 06a510a3890c02a2dae4b5a38fc3cdf4c690effe Mon Sep 17 00:00:00 2001 From: Lina Date: Tue, 6 May 2025 10:32:09 +0200 Subject: [PATCH 6/8] Faulty password messages --- pages/settings.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pages/settings.tsx b/pages/settings.tsx index e32a874..6dcb5e7 100644 --- a/pages/settings.tsx +++ b/pages/settings.tsx @@ -28,6 +28,7 @@ const Settings: NextPage = () => { const [activeAdminMessages, setActiveAdminMessages] = useState([]); const [isOidcInvitation, setIsOidcInvitation] = useState(false); const [backButtonDisabled, setBackButtonDisabled] = useState(false); + const [messages, setMessages] = useState(null); // Get ?flow=... from the URL const router = useRouter() const { flow: flowId, return_to: returnTo } = router.query @@ -116,7 +117,7 @@ const Settings: NextPage = () => { document.querySelector('button[value="Google"]')?.setAttribute("class", "hidden"); } } - }, [initialFlow, changedFlow]) + }, [initialFlow]) useEffect(() => { if (!changedFlow || !initialFlow) return; @@ -139,6 +140,13 @@ const Settings: NextPage = () => { } }, [isOidc, isOidcInvitation, initialFlow, changedFlow]); + useEffect(() => { + if (!changedFlow) return; + if (changedFlow.ui.messages) { + setMessages(changedFlow.ui.messages); + } + }, [changedFlow]) + const onSubmit = (values: UpdateSettingsFlowBody) => ory .updateSettingsFlow({ @@ -173,8 +181,8 @@ const Settings: NextPage = () => {

Profile management and security settings

+

Profile Settings

- Date: Tue, 6 May 2025 16:17:46 +0200 Subject: [PATCH 7/8] PR comments --- pages/settings.tsx | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/pages/settings.tsx b/pages/settings.tsx index 6dcb5e7..9bffed2 100644 --- a/pages/settings.tsx +++ b/pages/settings.tsx @@ -104,19 +104,21 @@ const Settings: NextPage = () => { setChangedFlow(initialFlow) //prevent password change option display if sso - if (["microsoft", "google"].includes(initialFlow.identity.metadata_public?.registration_scope?.provider_id)) { - initialFlow.ui.nodes = initialFlow.ui.nodes.filter((node: UiNode) => node.group !== "password"); - setIsOidc(true); - if (initialFlow.identity.metadata_public?.registration_scope?.invitation_sso) { - setIsOidcInvitation(true); - } - const provider = initialFlow.identity.metadata_public?.registration_scope?.provider_id; - if (provider === "google") { - document.querySelector('button[value="Microsoft"]')?.setAttribute("class", "hidden"); - } else if (provider === "microsoft") { - document.querySelector('button[value="Google"]')?.setAttribute("class", "hidden"); + requestAnimationFrame(() => { + if (["microsoft", "google"].includes(initialFlow.identity.metadata_public?.registration_scope?.provider_id)) { + initialFlow.ui.nodes = initialFlow.ui.nodes.filter((node: UiNode) => node.group !== "password"); + setIsOidc(true); + if (initialFlow.identity.metadata_public?.registration_scope?.invitation_sso) { + setIsOidcInvitation(true); + } + const provider = initialFlow.identity.metadata_public?.registration_scope?.provider_id; + if (provider === "google") { + document.querySelector('button[value="Microsoft"]')?.setAttribute("class", "hidden"); + } else if (provider === "microsoft") { + document.querySelector('button[value="Google"]')?.setAttribute("class", "hidden"); + } } - } + }); }, [initialFlow]) useEffect(() => { From d3c47be315d19b848330f4d6073230f09fba0365 Mon Sep 17 00:00:00 2001 From: Lina Date: Wed, 7 May 2025 15:45:05 +0200 Subject: [PATCH 8/8] Submodules merge --- submodules/react-components | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/submodules/react-components b/submodules/react-components index f29a797..66af8ce 160000 --- a/submodules/react-components +++ b/submodules/react-components @@ -1 +1 @@ -Subproject commit f29a797ab876fa443f0e90fa9dc7798e93cd397a +Subproject commit 66af8ce324318e31af8d6e2d812396d32dad57ef