Skip to content

Commit

Permalink
Nick/neos 622 navigating to home page results in no redirect (#1085)
Browse files Browse the repository at this point in the history
  • Loading branch information
nickzelei authored Jan 9, 2024
1 parent 0f36e21 commit 11c533a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion frontend/apps/web/components/providers/account-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export default function AccountProvider(props: Props): ReactElement {
const foundAccount = accountsResponse?.accounts.find(
(a) => a.name === accountName
);
if (userAccount?.id === foundAccount?.id) {
if (userAccount && foundAccount && userAccount?.id === foundAccount?.id) {
return;
}
if (foundAccount) {
Expand All @@ -68,6 +68,9 @@ export default function AccountProvider(props: Props): ReactElement {
if (!accountParam || accountParam !== foundAccount.name) {
router.push(`/${foundAccount.name}/jobs`);
}
} else if (accountName !== DEFAULT_ACCOUNT_NAME) {
setLastSelectedAccount(DEFAULT_ACCOUNT_NAME);
router.push(`/${DEFAULT_ACCOUNT_NAME}/jobs`);
}
}, [
userAccount?.id,
Expand Down
4 changes: 3 additions & 1 deletion frontend/apps/web/libs/hooks/useNeosyncUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ import { useGetSystemAppConfig } from './useGetSystemAppConfig';
* This hook should be called at least once in the app to ensure that the user record is set.
*/
export function useNeosyncUser(): HookReply<SetUserResponse> {
const { status } = useSession();
const { data: systemAppConfigData, isLoading: systemAppConfigLoading } =
useGetSystemAppConfig();
const { status } = useSession({
required: systemAppConfigData?.isAuthEnabled ?? false,
});
const isReady =
!systemAppConfigLoading &&
isReadyStatus(systemAppConfigData?.isAuthEnabled ?? false, status);
Expand Down

1 comment on commit 11c533a

@vercel
Copy link

@vercel vercel bot commented on 11c533a Jan 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.