-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into ahmed/DAPI-821/fix--sync-endpoint-configV3
- Loading branch information
Showing
18 changed files
with
272 additions
and
35 deletions.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import React from 'react'; | ||
import { Callback } from '@deriv-com/auth-client'; | ||
import { transformAccountsFromResponseBody } from '@site/src/utils'; | ||
import useAuthContext from '@site/src/hooks/useAuthContext'; | ||
const CallbackPage = () => { | ||
const { updateLoginAccounts } = useAuthContext(); | ||
return ( | ||
<Callback | ||
onSignInSuccess={(tokens) => { | ||
const accounts = transformAccountsFromResponseBody(tokens); | ||
updateLoginAccounts(accounts); | ||
window.location.href = '/'; | ||
}} | ||
/> | ||
); | ||
}; | ||
export default CallbackPage; |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import CallbackPage from './CallbackPage'; | ||
export default CallbackPage; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import useGrowthbookGetFeatureValue from '../useGrowthbookGetFeatureValue/'; | ||
import { | ||
requestOidcAuthentication, | ||
TOAuth2EnabledAppList, | ||
useIsOAuth2Enabled, | ||
} from '@deriv-com/auth-client'; | ||
/** | ||
* Handles the new login flow for the user using OIDC. | ||
* | ||
* If the user is not logged in and OAuth2 is enabled, it will redirect the user to the | ||
* OAuth2 authorization page from the OIDC config endpoint. If OAuth2 is not enabled it will | ||
* redirect the user to the legacy oauth url coming from the onClickLogin callback. | ||
* | ||
* @param {Object} props - The props object. | ||
* @param {Function} props.onClickLogin - The callback to be called when the user is logged in. | ||
* @returns {Object} - An object with the `handleLogin` function. | ||
*/ | ||
export const useHandleLogin = ({ onClickLogin }: { onClickLogin?: () => void }) => { | ||
const [OAuth2EnabledApps, OAuth2EnabledAppsInitialised] = | ||
useGrowthbookGetFeatureValue<TOAuth2EnabledAppList>({ | ||
featureFlag: 'hydra_be', | ||
}); | ||
const isOAuth2Enabled = useIsOAuth2Enabled(OAuth2EnabledApps, OAuth2EnabledAppsInitialised); | ||
const handleLogin = async () => { | ||
if (isOAuth2Enabled) { | ||
await requestOidcAuthentication({ | ||
redirectCallbackUri: `${window.location.origin}/callback`, | ||
}); | ||
} | ||
if (onClickLogin) { | ||
onClickLogin(); | ||
} | ||
}; | ||
return { handleLogin, isOAuth2Enabled }; | ||
}; |
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.