fix(): sleep before redirect (#9079)

## Summary
This Pull Request centralizes the redirection logic by introducing a
reusable `useRedirect` hook, which replaces direct usage of
`window.location.href` with more standardized and testable functionality
across multiple modules.

- Introduced a new `useRedirect` hook for handling redirection logic
with optional controlled delays.
- Refactored redirection implementations in various modules (`useAuth`,
workspace, and settings-related hooks, etc.) to use the newly introduced
`useRedirect` or related high-level hooks.
- Updated API and documentation to include or improve support for SSO,
particularly OIDC and SAML setup processes in server logic.
- Enhanced frontend and backend configurability with new environment
variable settings for SSO.

---------

Co-authored-by: Félix Malfait <felix@twenty.com>
This commit is contained in:
Antoine Moreaux
2024-12-16 15:15:55 +01:00
committed by GitHub
parent 9e9c1bdff1
commit f8f3945680
11 changed files with 45 additions and 22 deletions

View File

@ -6,6 +6,7 @@ import { useNavigate, useSearchParams } from 'react-router-dom';
import { MainButton, UndecoratedLink } from 'twenty-ui';
import { useAuthorizeAppMutation } from '~/generated/graphql';
import { isDefined } from '~/utils/isDefined';
import { useRedirect } from '@/domain-manager/hooks/useRedirect';
type App = { id: string; name: string; logo: string };
@ -55,6 +56,7 @@ const StyledButtonContainer = styled.div`
export const Authorize = () => {
const navigate = useNavigate();
const [searchParam] = useSearchParams();
const { redirect } = useRedirect();
//TODO: Replace with db call for registered third party apps
const [apps] = useState<App[]>([
{
@ -89,7 +91,7 @@ export const Authorize = () => {
redirectUrl,
},
onCompleted: (data) => {
window.location.href = data.authorizeApp.redirectUrl;
redirect(data.authorizeApp.redirectUrl);
},
});
}