Skip to content

Commit

Permalink
Merge pull request #1044 from near/signin_loop
Browse files Browse the repository at this point in the history
fix: avoid triggering the sign-in modal if user has already authenticated
  • Loading branch information
charleslavon authored Mar 7, 2024
2 parents d689e7d + e832ff9 commit f57f5ef
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
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

0 comments on commit f57f5ef

Please sign in to comment.