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": "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",

View File

@ -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()
} }
}) })

View File

@ -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',