Skip to content
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

fix: avoid triggering the sign-in modal if user has already authenticated #1044

Merged
merged 1 commit into from
Mar 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/pages/[componentAccountId]/widget/[componentName].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,10 @@ const ViewComponentPage: NextPageWithLayout = () => {

useEffect(() => {
const { requestAuth, createAccount } = componentProps;
if (requestAuth) {
if (requestAuth && !authStore.account) {
requestAuthentication(!!createAccount);
}
}, [componentProps, requestAuthentication]);
}, [authStore, componentProps, requestAuthentication]);

useEffect(() => {
setComponentSrc(componentSrc);
Expand Down
6 changes: 4 additions & 2 deletions src/pages/applications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@ import { useBosComponents } from '@/hooks/useBosComponents';
import { useDefaultLayout } from '@/hooks/useLayout';
import { useEffect } from 'react';
import { useRouter } from 'next/router';
import { useAuthStore } from '@/stores/auth';
import { useSignInRedirect } from '@/hooks/useSignInRedirect';
import type { NextPageWithLayout } from '@/utils/types';

const ApplicationsPage: NextPageWithLayout = () => {
const components = useBosComponents();
const router = useRouter();
const { requestAuthentication } = useSignInRedirect();
const authStore = useAuthStore();

useEffect(() => {
const { requestAuth, createAccount } = router.query;
if (requestAuth) {
if (requestAuth && !authStore.account) {
requestAuthentication(!!createAccount);
}
}, [requestAuthentication, router.query]);
}, [authStore, requestAuthentication, router.query]);

return (
<ComponentWrapperPage
Expand Down
Loading