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:
@ -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);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user