get-author-fix
Some checks failed
deploy / test (push) Successful in 1m16s
deploy / Update templates on Mailgun (push) Failing after 5s

This commit is contained in:
Untone 2024-01-10 15:39:02 +03:00
parent 45a5f0c542
commit 59eb0265bf
3 changed files with 10 additions and 5 deletions

View File

@ -19,8 +19,7 @@
"lint:styles": "stylelint **/*.{scss,css}",
"lint:styles:fix": "stylelint **/*.{scss,css} --fix",
"pre-commit": "lint-staged",
"pre-push": "",
"pre-push-old": "npm run typecheck",
"pre-push": "npm run typecheck",
"prepare": "husky install",
"preview": "vite preview",
"start": "vite",

View File

@ -12,10 +12,14 @@ type Props = {
}
export const AuthGuard = (props: Props) => {
const { isAuthenticated, isSessionLoaded } = useSession()
const {
isAuthenticated,
isSessionLoaded,
actions: { loadSession },
} = useSession()
const { changeSearchParams } = useRouter<RootSearchParams & AuthModalSearchParams>()
createEffect(() => {
createEffect(async () => {
if (props.disabled) {
return
}
@ -31,6 +35,8 @@ export const AuthGuard = (props: Props) => {
true,
)
}
} else {
await loadSession()
}
})

View File

@ -128,7 +128,7 @@ export const SessionProvider = (props: {
const [author, { refetch: loadAuthor, mutate: setAuthor }] = createResource<Author | null>(
async () => {
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',