0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-01-06 20:40:08 -05:00

fix(experience): fix the terms of use not clickable bug (#5670)

* fix(experience): fix the terms of use not clickable bug

fix the terms of use not clickable bug

* chore: remove changeset

remove changeset
This commit is contained in:
simeng-li 2024-04-10 11:51:52 +08:00 committed by GitHub
parent 5131cf7da3
commit e1d4df4fc3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 15 additions and 7 deletions

View file

@ -17,9 +17,9 @@ const SingleSignOn = ({ connectorId }: Props) => {
*/ */
useNativeMessageListener(socialConnectors.length > 0); useNativeMessageListener(socialConnectors.length > 0);
useSingleSignOnListener(connectorId); const { loading } = useSingleSignOnListener(connectorId);
return <LoadingLayer />; return loading ? <LoadingLayer /> : null;
}; };
export default SingleSignOn; export default SingleSignOn;

View file

@ -10,9 +10,9 @@ type Props = {
}; };
const SocialSignIn = ({ connectorId }: Props) => { const SocialSignIn = ({ connectorId }: Props) => {
useSocialSignInListener(connectorId); const { loading } = useSocialSignInListener(connectorId);
return <LoadingLayer />; return loading ? <LoadingLayer /> : null;
}; };
export default SocialSignIn; export default SocialSignIn;

View file

@ -1,5 +1,5 @@
import { SignInMode } from '@logto/schemas'; import { SignInMode } from '@logto/schemas';
import { useState, useCallback, useEffect } from 'react'; import { useCallback, useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { useSearchParams } from 'react-router-dom'; import { useSearchParams } from 'react-router-dom';
@ -52,6 +52,7 @@ const useSingleSignOnRegister = () => {
const useSingleSignOnListener = (connectorId: string) => { const useSingleSignOnListener = (connectorId: string) => {
const { t } = useTranslation(); const { t } = useTranslation();
const [loading, setLoading] = useState(true);
const [isConsumed, setIsConsumed] = useState(false); const [isConsumed, setIsConsumed] = useState(false);
const [searchParameters, setSearchParameters] = useSearchParams(); const [searchParameters, setSearchParameters] = useSearchParams();
const { setToast } = useToast(); const { setToast } = useToast();
@ -71,6 +72,7 @@ const useSingleSignOnListener = (connectorId: string) => {
}); });
if (error) { if (error) {
setLoading(false);
await handleError(error, { await handleError(error, {
'user.identity_not_exist': async (error) => { 'user.identity_not_exist': async (error) => {
// Should not let user register new social account under sign-in only mode // Should not let user register new social account under sign-in only mode
@ -128,6 +130,8 @@ const useSingleSignOnListener = (connectorId: string) => {
singleSignOnHandler, singleSignOnHandler,
t, t,
]); ]);
return { loading };
}; };
export default useSingleSignOnListener; export default useSingleSignOnListener;

View file

@ -1,14 +1,14 @@
import type { RequestErrorBody } from '@logto/schemas'; import type { RequestErrorBody } from '@logto/schemas';
import { SignInMode } from '@logto/schemas'; import { SignInMode } from '@logto/schemas';
import { useEffect, useCallback, useMemo, useState } from 'react'; import { useCallback, useEffect, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { useNavigate, useSearchParams } from 'react-router-dom'; import { useNavigate, useSearchParams } from 'react-router-dom';
import { validate } from 'superstruct'; import { validate } from 'superstruct';
import { signInWithSocial } from '@/apis/interaction'; import { signInWithSocial } from '@/apis/interaction';
import useApi from '@/hooks/use-api'; import useApi from '@/hooks/use-api';
import useErrorHandler from '@/hooks/use-error-handler';
import type { ErrorHandlers } from '@/hooks/use-error-handler'; import type { ErrorHandlers } from '@/hooks/use-error-handler';
import useErrorHandler from '@/hooks/use-error-handler';
import usePreSignInErrorHandler from '@/hooks/use-pre-sign-in-error-handler'; import usePreSignInErrorHandler from '@/hooks/use-pre-sign-in-error-handler';
import { useSieMethods } from '@/hooks/use-sie'; import { useSieMethods } from '@/hooks/use-sie';
import useSocialRegister from '@/hooks/use-social-register'; import useSocialRegister from '@/hooks/use-social-register';
@ -19,6 +19,7 @@ import { parseQueryParameters } from '@/utils';
import { stateValidation } from '@/utils/social-connectors'; import { stateValidation } from '@/utils/social-connectors';
const useSocialSignInListener = (connectorId: string) => { const useSocialSignInListener = (connectorId: string) => {
const [loading, setLoading] = useState(true);
const { setToast } = useToast(); const { setToast } = useToast();
const { signInMode } = useSieMethods(); const { signInMode } = useSieMethods();
const { t } = useTranslation(); const { t } = useTranslation();
@ -90,6 +91,7 @@ const useSocialSignInListener = (connectorId: string) => {
}); });
if (error) { if (error) {
setLoading(false);
await handleError(error, signInWithSocialErrorHandlers); await handleError(error, signInWithSocialErrorHandlers);
return; return;
@ -130,6 +132,8 @@ const useSocialSignInListener = (connectorId: string) => {
signInWithSocialHandler, signInWithSocialHandler,
t, t,
]); ]);
return { loading };
}; };
export default useSocialSignInListener; export default useSocialSignInListener;