get-author-fix
This commit is contained in:
parent
45a5f0c542
commit
59eb0265bf
|
@ -19,8 +19,7 @@
|
||||||
"lint:styles": "stylelint **/*.{scss,css}",
|
"lint:styles": "stylelint **/*.{scss,css}",
|
||||||
"lint:styles:fix": "stylelint **/*.{scss,css} --fix",
|
"lint:styles:fix": "stylelint **/*.{scss,css} --fix",
|
||||||
"pre-commit": "lint-staged",
|
"pre-commit": "lint-staged",
|
||||||
"pre-push": "",
|
"pre-push": "npm run typecheck",
|
||||||
"pre-push-old": "npm run typecheck",
|
|
||||||
"prepare": "husky install",
|
"prepare": "husky install",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"start": "vite",
|
"start": "vite",
|
||||||
|
|
|
@ -12,10 +12,14 @@ type Props = {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const AuthGuard = (props: Props) => {
|
export const AuthGuard = (props: Props) => {
|
||||||
const { isAuthenticated, isSessionLoaded } = useSession()
|
const {
|
||||||
|
isAuthenticated,
|
||||||
|
isSessionLoaded,
|
||||||
|
actions: { loadSession },
|
||||||
|
} = useSession()
|
||||||
const { changeSearchParams } = useRouter<RootSearchParams & AuthModalSearchParams>()
|
const { changeSearchParams } = useRouter<RootSearchParams & AuthModalSearchParams>()
|
||||||
|
|
||||||
createEffect(() => {
|
createEffect(async () => {
|
||||||
if (props.disabled) {
|
if (props.disabled) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -31,6 +35,8 @@ export const AuthGuard = (props: Props) => {
|
||||||
true,
|
true,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
await loadSession()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -128,7 +128,7 @@ export const SessionProvider = (props: {
|
||||||
const [author, { refetch: loadAuthor, mutate: setAuthor }] = createResource<Author | null>(
|
const [author, { refetch: loadAuthor, mutate: setAuthor }] = createResource<Author | null>(
|
||||||
async () => {
|
async () => {
|
||||||
const u = session()?.user
|
const u = session()?.user
|
||||||
return u ? (await apiClient.getAuthorId({ user: u.id })) || null : null
|
return u ? (await apiClient.getAuthorId({ user: u.id.trim() })) || null : null
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ssrLoadFrom: 'initial',
|
ssrLoadFrom: 'initial',
|
||||||
|
|
Loading…
Reference in New Issue
Block a user