Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ import {type AuthState, type AuthStoreState} from './authStore'

export const subscribeToStateAndFetchCurrentUser = ({
state,
instance,
}: StoreContext<AuthStoreState>): Subscription => {
const {clientFactory, apiHost} = state.get().options
const useProjectHostname = !!instance.config.studioMode?.enabled
const projectId = instance.config.projectId

const currentUser$ = state.observable
.pipe(
Expand All @@ -28,8 +31,9 @@ export const subscribeToStateAndFetchCurrentUser = ({
requestTagPrefix: REQUEST_TAG_PREFIX,
token,
ignoreBrowserTokenWarning: true,
useProjectHostname: false,
useProjectHostname,
useCdn: false,
...(useProjectHostname && projectId ? {projectId} : {}),
...(apiHost && {apiHost}),
}),
),
Expand Down
7 changes: 6 additions & 1 deletion packages/react/src/components/auth/AuthBoundary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {ComlinkTokenRefreshProvider} from '../../context/ComlinkTokenRefresh'
import {useAuthState} from '../../hooks/auth/useAuthState'
import {useLoginUrl} from '../../hooks/auth/useLoginUrl'
import {useVerifyOrgProjects} from '../../hooks/auth/useVerifyOrgProjects'
import {useSanityInstance} from '../../hooks/context/useSanityInstance'
import {useCorsOriginError} from '../../hooks/errors/useCorsOriginError'
import {CorsErrorComponent} from '../errors/CorsErrorComponent'
import {isInIframe} from '../utils'
Expand Down Expand Up @@ -169,7 +170,11 @@ function AuthSwitch({
...props
}: AuthSwitchProps) {
const authState = useAuthState()
const orgError = useVerifyOrgProjects(!verifyOrganization, projectIds)
const instance = useSanityInstance()
const studioModeEnabled = instance.config.studioMode?.enabled
const disableVerifyOrg =
!verifyOrganization || studioModeEnabled || authState.type !== AuthStateType.LOGGED_IN
const orgError = useVerifyOrgProjects(disableVerifyOrg, projectIds)

const isLoggedOut = authState.type === AuthStateType.LOGGED_OUT && !authState.isDestroyingSession
const loginUrl = useLoginUrl()
Expand Down
Loading