Skip to content

Commit

Permalink
fix infinite loop in producer anonymous page
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminpochat committed Dec 2, 2024
1 parent 25e7fdd commit 6f3510e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion frontend/app/src/layouts/producer/AnonymousLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default function AnonymousLayout() {
}
console.log('loadEnvironmentType')
loadEnvironmentType()
}, [environmentTypeService])
}, [])

const Item = styled(Paper)(({ theme }) => ({
backgroundColor: theme.palette.mode === 'dark' ? '#1A2027' : '#fff',
Expand Down
10 changes: 6 additions & 4 deletions frontend/app/src/layouts/producer/AuthenticatedLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ export default function AuthenticatedLayout() {
const authenticationService = new AuthenticationService(keycloak)
const urlService = new UrlService()

const {authenticatedAsCustomer, environmentType}: {isAuthenticatedAsCustomer: boolean, environmentType: {label: String, color: String} | undefined} = useLoaderData()
const data = useLoaderData()
const authenticatedAsCustomer: boolean = data.isAuthenticatedAsCustomer
const environmentType = data.environmentType

const sideMenuWidth = 240;

Expand Down Expand Up @@ -100,11 +102,11 @@ export default function AuthenticatedLayout() {

if (!authenticationService.isAuthenticated()) {
return <Navigate to='/authentication' />
} else if (authenticatedAsCustomer) {
}
if (authenticatedAsCustomer) {
return <Navigate to='/unauthorized' />
} else {
return getAuthenticatedLayout()
}
return getAuthenticatedLayout()
}

export async function loadAuthenticatedLayoutData(keycloak): Promise<{isAuthenticatedAsCustomer: boolean, environmentType: {label: String, color: String} | undefined}> {
Expand Down

0 comments on commit 6f3510e

Please sign in to comment.