-
Notifications
You must be signed in to change notification settings - Fork 204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: implemented redirects using context.config #2755
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
613625c
feat: implemented redirects using context.config
chesterkmr e517986
fix(vscode): submodule search issue
alonp99 c36c4cb
chore(docs): webhooks schema
alonp99 9d512f0
Merge branch 'dev' into illiar/feat/kyb-config-redirects
alonp99 487bc8d
fix(vscode): submodule search issue
alonp99 d33145c
Merge branch 'dev' into illiar/feat/kyb-config-redirects
alonp99 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 24 additions & 4 deletions
28
apps/kyb-app/src/hooks/useUIOptionsRedirect/useUIOptionsRedirect.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,33 @@ | ||
import { useStateManagerContext } from '@/components/organisms/DynamicUI/StateManager/components/StateProvider'; | ||
import { UIOptions } from '@/domains/collection-flow'; | ||
import { useLanguage } from '@/hooks/useLanguage'; | ||
import { useUISchemasQuery } from '@/hooks/useUISchemasQuery'; | ||
import { useEffect } from 'react'; | ||
import { useEffect, useMemo } from 'react'; | ||
|
||
export const useUIOptionsRedirect = (state: 'success' | 'failure') => { | ||
const { data } = useUISchemasQuery(useLanguage()); | ||
const { config } = useStateManagerContext(); | ||
|
||
const uiOptions: UIOptions | null = useMemo(() => { | ||
// Config has priority over uiOptions in data | ||
if (config?.uiOptions?.redirectUrls) return config.uiOptions; | ||
|
||
if (data?.uiOptions?.redirectUrls) return data.uiOptions; | ||
|
||
return null; | ||
}, [data, config]); | ||
|
||
const redirectUrls: UIOptions['redirectUrls'] | null = useMemo(() => { | ||
if (!uiOptions) return null; | ||
|
||
return uiOptions.redirectUrls; | ||
}, [uiOptions]); | ||
|
||
useEffect(() => { | ||
if (data?.uiOptions?.redirectUrls?.[state]) { | ||
location.href = data.uiOptions.redirectUrls?.[state] as string; | ||
if (redirectUrls?.[state]) { | ||
const redirectUrl = redirectUrls[state] as string; | ||
console.info(`Collection Flow resolved to ${state}. Redirecting to ${redirectUrl}`); | ||
location.href = redirectUrls[state] as string; | ||
} | ||
}, [data, state]); | ||
}, [redirectUrls, state]); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule data-migrations
updated
from f063d7 to 0d82f7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Validate redirect URLs to prevent potential security risks
Since the redirect URLs are sourced from configuration or data, there is a potential risk if these URLs are not validated. To prevent open redirect vulnerabilities, consider adding validation to ensure that the
redirectUrl
is an allowed domain or matches an expected pattern before performing the redirection.