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 not redirecting to no access page on signin or init item when the user has no access in new interfaces #3828

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 2 additions & 8 deletions packages-next/auth/src/pages/InitPage.tsx
Expand Up @@ -21,7 +21,7 @@ export const InitPage = ({
mutation: DocumentNode;
showKeystoneSignup: boolean;
}) => {
const { fieldViews, adminMeta, authenticatedItem } = useRawKeystone();
const { fieldViews } = useRawKeystone();
const fields = useMemo(() => {
const fields: Record<string, FieldMeta> = {};
Object.keys(serializedFields).forEach(fieldPath => {
Expand Down Expand Up @@ -77,14 +77,8 @@ export const InitPage = ({
),
},
});
if (adminMeta.state === 'error') {
adminMeta.refetch();
}
if (authenticatedItem.state !== 'loading') {
authenticatedItem.refetch();
}

await router.push('/');
window.location.reload();
}}
>
{error && <Notice>{error.message}</Notice>}
Expand Down
13 changes: 2 additions & 11 deletions packages-next/auth/src/pages/SigninPage.tsx
Expand Up @@ -6,7 +6,6 @@ import { jsx, H1, Stack } from '@keystone-ui/core';
import { Button } from '@keystone-ui/button';
import { TextInput } from '@keystone-ui/fields';
import { Notice } from '@keystone-ui/notice';
import { useRawKeystone } from '@keystone-spike/admin-ui';

import { SigninContainer } from '../components/SigninContainer';
import { useMutation, DocumentNode } from '@keystone-spike/admin-ui/apollo';
Expand All @@ -28,8 +27,6 @@ export const SigninPage = ({ mutation }: { mutation: DocumentNode }) => {
identityFieldRef.current?.focus();
}, [mode]);

const { adminMeta, authenticatedItem } = useRawKeystone();

const [mutate, { error, loading }] = useMutation(mutation);

return (
Expand All @@ -49,17 +46,11 @@ export const SigninPage = ({ mutation }: { mutation: DocumentNode }) => {
secret: state.secret,
},
});
if (adminMeta.state === 'error') {
adminMeta.refetch();
}
if (authenticatedItem.state !== 'loading') {
authenticatedItem.refetch();
}
} catch (err) {
return;
}

router.push('/');
await router.push('/');
window.location.reload();
}
}}
>
Expand Down