Commit 7da21afd authored by Stefan Probst's avatar Stefan Probst
Browse files

fix: ensure get user data is authenticated

parent 79a078be
Pipeline #210143 canceled with stages
in 1 minute and 40 seconds
...@@ -8,7 +8,8 @@ import type { UseMutationOptions, UseMutationResult } from 'react-query' ...@@ -8,7 +8,8 @@ import type { UseMutationOptions, UseMutationResult } from 'react-query'
import { useMutation } from 'react-query' import { useMutation } from 'react-query'
import type { ImplicitGrantTokenData, OAuthRegistrationDto } from '@/api/sshoc' import type { ImplicitGrantTokenData, OAuthRegistrationDto } from '@/api/sshoc'
import { baseUrl, request } from '@/api/sshoc' import { baseUrl, request, useGetLoggedInUser } from '@/api/sshoc'
import { useAuth } from '@/modules/auth/AuthContext'
/** /**
* Sign in user with username and password. * Sign in user with username and password.
...@@ -191,3 +192,23 @@ export function getMediaFileUrl({ mediaId }: { mediaId: string }): string { ...@@ -191,3 +192,23 @@ export function getMediaFileUrl({ mediaId }: { mediaId: string }): string {
) )
return String(url) return String(url)
} }
export function useCurrentUser(): ReturnType<typeof useGetLoggedInUser> {
const auth = useAuth()
return useGetLoggedInUser(
{
enabled: auth.session?.accessToken !== undefined,
/** immediately sign out in case of error */
retry: false,
/** cache until cache is cleared manually */
staleTime: Infinity,
onError() {
auth.signOut()
},
},
{
token: auth.session?.accessToken,
},
)
}
...@@ -2,7 +2,8 @@ import { useRouter } from 'next/router' ...@@ -2,7 +2,8 @@ import { useRouter } from 'next/router'
import { useQueryClient } from 'react-query' import { useQueryClient } from 'react-query'
import type { DatasetCore, DatasetDto } from '@/api/sshoc' import type { DatasetCore, DatasetDto } from '@/api/sshoc'
import { useCreateDataset, useGetLoggedInUser } from '@/api/sshoc' import { useCreateDataset } from '@/api/sshoc'
import { useCurrentUser } from '@/api/sshoc/client'
import type { ItemCategory } from '@/api/sshoc/types' import type { ItemCategory } from '@/api/sshoc/types'
import { ActorsFormSection } from '@/components/item/ActorsFormSection/ActorsFormSection' import { ActorsFormSection } from '@/components/item/ActorsFormSection/ActorsFormSection'
import { DateFormSection } from '@/components/item/DateFormSection/DateFormSection' import { DateFormSection } from '@/components/item/DateFormSection/DateFormSection'
...@@ -43,7 +44,7 @@ export function ItemForm(props: ItemFormProps<ItemFormValues>): JSX.Element { ...@@ -43,7 +44,7 @@ export function ItemForm(props: ItemFormProps<ItemFormValues>): JSX.Element {
const toast = useToast() const toast = useToast()
const router = useRouter() const router = useRouter()
const auth = useAuth() const auth = useAuth()
const user = useGetLoggedInUser() const user = useCurrentUser()
const handleErrors = useErrorHandlers() const handleErrors = useErrorHandlers()
const validateCommonFormFields = useValidateCommonFormFields() const validateCommonFormFields = useValidateCommonFormFields()
const isAllowedToPublish = const isAllowedToPublish =
......
...@@ -2,7 +2,8 @@ import { useRouter } from 'next/router' ...@@ -2,7 +2,8 @@ import { useRouter } from 'next/router'
import { useQueryClient } from 'react-query' import { useQueryClient } from 'react-query'
import type { DatasetCore, DatasetDto } from '@/api/sshoc' import type { DatasetCore, DatasetDto } from '@/api/sshoc'
import { useGetLoggedInUser, useUpdateDataset } from '@/api/sshoc' import { useUpdateDataset } from '@/api/sshoc'
import { useCurrentUser } from '@/api/sshoc/client'
import type { ItemCategory } from '@/api/sshoc/types' import type { ItemCategory } from '@/api/sshoc/types'
import { ActorsFormSection } from '@/components/item/ActorsFormSection/ActorsFormSection' import { ActorsFormSection } from '@/components/item/ActorsFormSection/ActorsFormSection'
import { DateFormSection } from '@/components/item/DateFormSection/DateFormSection' import { DateFormSection } from '@/components/item/DateFormSection/DateFormSection'
...@@ -48,7 +49,7 @@ export function ItemForm(props: ItemFormProps<ItemFormValues>): JSX.Element { ...@@ -48,7 +49,7 @@ export function ItemForm(props: ItemFormProps<ItemFormValues>): JSX.Element {
const toast = useToast() const toast = useToast()
const router = useRouter() const router = useRouter()
const auth = useAuth() const auth = useAuth()
const user = useGetLoggedInUser() const user = useCurrentUser()
const handleErrors = useErrorHandlers() const handleErrors = useErrorHandlers()
const validateCommonFormFields = useValidateCommonFormFields() const validateCommonFormFields = useValidateCommonFormFields()
const isAllowedToPublish = const isAllowedToPublish =
......
...@@ -2,7 +2,8 @@ import { useRouter } from 'next/router' ...@@ -2,7 +2,8 @@ import { useRouter } from 'next/router'
import { useQueryClient } from 'react-query' import { useQueryClient } from 'react-query'
import type { PublicationCore, PublicationDto } from '@/api/sshoc' import type { PublicationCore, PublicationDto } from '@/api/sshoc'
import { useCreatePublication, useGetLoggedInUser } from '@/api/sshoc' import { useCreatePublication } from '@/api/sshoc'
import { useCurrentUser } from '@/api/sshoc/client'
import type { ItemCategory } from '@/api/sshoc/types' import type { ItemCategory } from '@/api/sshoc/types'
import { ActorsFormSection } from '@/components/item/ActorsFormSection/ActorsFormSection' import { ActorsFormSection } from '@/components/item/ActorsFormSection/ActorsFormSection'
import { DateFormSection } from '@/components/item/DateFormSection/DateFormSection' import { DateFormSection } from '@/components/item/DateFormSection/DateFormSection'
...@@ -43,7 +44,7 @@ export function ItemForm(props: ItemFormProps<ItemFormValues>): JSX.Element { ...@@ -43,7 +44,7 @@ export function ItemForm(props: ItemFormProps<ItemFormValues>): JSX.Element {
const toast = useToast() const toast = useToast()
const router = useRouter() const router = useRouter()
const auth = useAuth() const auth = useAuth()
const user = useGetLoggedInUser() const user = useCurrentUser()
const handleErrors = useErrorHandlers() const handleErrors = useErrorHandlers()
const validateCommonFormFields = useValidateCommonFormFields() const validateCommonFormFields = useValidateCommonFormFields()
const isAllowedToPublish = const isAllowedToPublish =
......
...@@ -2,7 +2,8 @@ import { useRouter } from 'next/router' ...@@ -2,7 +2,8 @@ import { useRouter } from 'next/router'
import { useQueryClient } from 'react-query' import { useQueryClient } from 'react-query'
import type { PublicationCore, PublicationDto } from '@/api/sshoc' import type { PublicationCore, PublicationDto } from '@/api/sshoc'
import { useGetLoggedInUser, useUpdatePublication } from '@/api/sshoc' import { useUpdatePublication } from '@/api/sshoc'
import { useCurrentUser } from '@/api/sshoc/client'
import type { ItemCategory } from '@/api/sshoc/types' import type { ItemCategory } from '@/api/sshoc/types'
import { ActorsFormSection } from '@/components/item/ActorsFormSection/ActorsFormSection' import { ActorsFormSection } from '@/components/item/ActorsFormSection/ActorsFormSection'
import { DateFormSection } from '@/components/item/DateFormSection/DateFormSection' import { DateFormSection } from '@/components/item/DateFormSection/DateFormSection'
...@@ -48,7 +49,7 @@ export function ItemForm(props: ItemFormProps<ItemFormValues>): JSX.Element { ...@@ -48,7 +49,7 @@ export function ItemForm(props: ItemFormProps<ItemFormValues>): JSX.Element {
const toast = useToast() const toast = useToast()
const router = useRouter() const router = useRouter()
const auth = useAuth() const auth = useAuth()
const user = useGetLoggedInUser() const user = useCurrentUser()
const handleErrors = useErrorHandlers() const handleErrors = useErrorHandlers()
const validateCommonFormFields = useValidateCommonFormFields() const validateCommonFormFields = useValidateCommonFormFields()
const isAllowedToPublish = const isAllowedToPublish =
......
...@@ -2,7 +2,8 @@ import { useRouter } from 'next/router' ...@@ -2,7 +2,8 @@ import { useRouter } from 'next/router'
import { useQueryClient } from 'react-query' import { useQueryClient } from 'react-query'
import type { ToolCore, ToolDto } from '@/api/sshoc' import type { ToolCore, ToolDto } from '@/api/sshoc'
import { useCreateTool, useGetLoggedInUser } from '@/api/sshoc' import { useCreateTool } from '@/api/sshoc'
import { useCurrentUser } from '@/api/sshoc/client'
import type { ItemCategory } from '@/api/sshoc/types' import type { ItemCategory } from '@/api/sshoc/types'
import { ActorsFormSection } from '@/components/item/ActorsFormSection/ActorsFormSection' import { ActorsFormSection } from '@/components/item/ActorsFormSection/ActorsFormSection'
import { MainFormSection } from '@/components/item/MainFormSection/MainFormSection' import { MainFormSection } from '@/components/item/MainFormSection/MainFormSection'
...@@ -41,7 +42,7 @@ export function ItemForm(props: ItemFormProps<ItemFormValues>): JSX.Element { ...@@ -41,7 +42,7 @@ export function ItemForm(props: ItemFormProps<ItemFormValues>): JSX.Element {
const toast = useToast() const toast = useToast()
const router = useRouter() const router = useRouter()
const auth = useAuth() const auth = useAuth()
const user = useGetLoggedInUser() const user = useCurrentUser()
const handleErrors = useErrorHandlers() const handleErrors = useErrorHandlers()
const validateCommonFormFields = useValidateCommonFormFields() const validateCommonFormFields = useValidateCommonFormFields()
const isAllowedToPublish = const isAllowedToPublish =
......
...@@ -2,7 +2,8 @@ import { useRouter } from 'next/router' ...@@ -2,7 +2,8 @@ import { useRouter } from 'next/router'
import { useQueryClient } from 'react-query' import { useQueryClient } from 'react-query'
import type { ToolCore, ToolDto } from '@/api/sshoc' import type { ToolCore, ToolDto } from '@/api/sshoc'
import { useGetLoggedInUser, useUpdateTool } from '@/api/sshoc' import { useUpdateTool } from '@/api/sshoc'
import { useCurrentUser } from '@/api/sshoc/client'
import type { ItemCategory } from '@/api/sshoc/types' import type { ItemCategory } from '@/api/sshoc/types'
import { ActorsFormSection } from '@/components/item/ActorsFormSection/ActorsFormSection' import { ActorsFormSection } from '@/components/item/ActorsFormSection/ActorsFormSection'
import { MainFormSection } from '@/components/item/MainFormSection/MainFormSection' import { MainFormSection } from '@/components/item/MainFormSection/MainFormSection'
...@@ -46,7 +47,7 @@ export function ItemForm(props: ItemFormProps<ItemFormValues>): JSX.Element { ...@@ -46,7 +47,7 @@ export function ItemForm(props: ItemFormProps<ItemFormValues>): JSX.Element {
const toast = useToast() const toast = useToast()
const router = useRouter() const router = useRouter()
const auth = useAuth() const auth = useAuth()
const user = useGetLoggedInUser() const user = useCurrentUser()
const handleErrors = useErrorHandlers() const handleErrors = useErrorHandlers()
const validateCommonFormFields = useValidateCommonFormFields() const validateCommonFormFields = useValidateCommonFormFields()
const isAllowedToPublish = const isAllowedToPublish =
......
...@@ -2,7 +2,8 @@ import { useRouter } from 'next/router' ...@@ -2,7 +2,8 @@ import { useRouter } from 'next/router'
import { useQueryClient } from 'react-query' import { useQueryClient } from 'react-query'
import type { TrainingMaterialCore, TrainingMaterialDto } from '@/api/sshoc' import type { TrainingMaterialCore, TrainingMaterialDto } from '@/api/sshoc'
import { useCreateTrainingMaterial, useGetLoggedInUser } from '@/api/sshoc' import { useCreateTrainingMaterial } from '@/api/sshoc'
import { useCurrentUser } from '@/api/sshoc/client'
import type { ItemCategory } from '@/api/sshoc/types' import type { ItemCategory } from '@/api/sshoc/types'
import { ActorsFormSection } from '@/components/item/ActorsFormSection/ActorsFormSection' import { ActorsFormSection } from '@/components/item/ActorsFormSection/ActorsFormSection'
import { MainFormSection } from '@/components/item/MainFormSection/MainFormSection' import { MainFormSection } from '@/components/item/MainFormSection/MainFormSection'
...@@ -41,7 +42,7 @@ export function ItemForm(props: ItemFormProps<ItemFormValues>): JSX.Element { ...@@ -41,7 +42,7 @@ export function ItemForm(props: ItemFormProps<ItemFormValues>): JSX.Element {
const toast = useToast() const toast = useToast()
const router = useRouter() const router = useRouter()
const auth = useAuth() const auth = useAuth()
const user = useGetLoggedInUser() const user = useCurrentUser()
const handleErrors = useErrorHandlers() const handleErrors = useErrorHandlers()
const validateCommonFormFields = useValidateCommonFormFields() const validateCommonFormFields = useValidateCommonFormFields()
const isAllowedToPublish = const isAllowedToPublish =
......
...@@ -2,7 +2,8 @@ import { useRouter } from 'next/router' ...@@ -2,7 +2,8 @@ import { useRouter } from 'next/router'
import { useQueryClient } from 'react-query' import { useQueryClient } from 'react-query'
import type { TrainingMaterialCore, TrainingMaterialDto } from '@/api/sshoc' import type { TrainingMaterialCore, TrainingMaterialDto } from '@/api/sshoc'
import { useGetLoggedInUser, useUpdateTrainingMaterial } from '@/api/sshoc' import { useUpdateTrainingMaterial } from '@/api/sshoc'
import { useCurrentUser } from '@/api/sshoc/client'
import type { ItemCategory } from '@/api/sshoc/types' import type { ItemCategory } from '@/api/sshoc/types'
import { ActorsFormSection } from '@/components/item/ActorsFormSection/ActorsFormSection' import { ActorsFormSection } from '@/components/item/ActorsFormSection/ActorsFormSection'
import { MainFormSection } from '@/components/item/MainFormSection/MainFormSection' import { MainFormSection } from '@/components/item/MainFormSection/MainFormSection'
...@@ -46,7 +47,7 @@ export function ItemForm(props: ItemFormProps<ItemFormValues>): JSX.Element { ...@@ -46,7 +47,7 @@ export function ItemForm(props: ItemFormProps<ItemFormValues>): JSX.Element {
const toast = useToast() const toast = useToast()
const router = useRouter() const router = useRouter()
const auth = useAuth() const auth = useAuth()
const user = useGetLoggedInUser() const user = useCurrentUser()
const handleErrors = useErrorHandlers() const handleErrors = useErrorHandlers()
const validateCommonFormFields = useValidateCommonFormFields() const validateCommonFormFields = useValidateCommonFormFields()
const isAllowedToPublish = const isAllowedToPublish =
......
...@@ -10,11 +10,8 @@ import { Fragment, useEffect, useRef, useState } from 'react' ...@@ -10,11 +10,8 @@ import { Fragment, useEffect, useRef, useState } from 'react'
import { useQueryClient } from 'react-query' import { useQueryClient } from 'react-query'
import type { StepCore, WorkflowCore, WorkflowDto } from '@/api/sshoc' import type { StepCore, WorkflowCore, WorkflowDto } from '@/api/sshoc'
import { import { useCreateStep, useCreateWorkflow } from '@/api/sshoc'
useCreateStep, import { useCurrentUser } from '@/api/sshoc/client'
useCreateWorkflow,
useGetLoggedInUser,
} from '@/api/sshoc'
import type { ItemCategory } from '@/api/sshoc/types' import type { ItemCategory } from '@/api/sshoc/types'
import { ActorsFormSection } from '@/components/item/ActorsFormSection/ActorsFormSection' import { ActorsFormSection } from '@/components/item/ActorsFormSection/ActorsFormSection'
import { MainFormSection } from '@/components/item/MainFormSection/MainFormSection' import { MainFormSection } from '@/components/item/MainFormSection/MainFormSection'
...@@ -59,7 +56,7 @@ export function ItemForm(props: ItemFormProps<ItemFormValues>): JSX.Element { ...@@ -59,7 +56,7 @@ export function ItemForm(props: ItemFormProps<ItemFormValues>): JSX.Element {
const toast = useToast() const toast = useToast()
const router = useRouter() const router = useRouter()
const auth = useAuth() const auth = useAuth()
const user = useGetLoggedInUser() const user = useCurrentUser()
const handleErrors = useErrorHandlers() const handleErrors = useErrorHandlers()
const validateCommonFormFields = useValidateCommonFormFields() const validateCommonFormFields = useValidateCommonFormFields()
const isAllowedToPublish = const isAllowedToPublish =
......
...@@ -10,12 +10,8 @@ import { Fragment, useEffect, useRef, useState } from 'react' ...@@ -10,12 +10,8 @@ import { Fragment, useEffect, useRef, useState } from 'react'
import { useQueryClient } from 'react-query' import { useQueryClient } from 'react-query'
import type { StepCore, WorkflowCore, WorkflowDto } from '@/api/sshoc' import type { StepCore, WorkflowCore, WorkflowDto } from '@/api/sshoc'
import { import { useCreateStep, useUpdateStep, useUpdateWorkflow } from '@/api/sshoc'
useCreateStep, import { useCurrentUser } from '@/api/sshoc/client'
useGetLoggedInUser,
useUpdateStep,
useUpdateWorkflow,
} from '@/api/sshoc'
import type { ItemCategory } from '@/api/sshoc/types' import type { ItemCategory } from '@/api/sshoc/types'
import { ActorsFormSection } from '@/components/item/ActorsFormSection/ActorsFormSection' import { ActorsFormSection } from '@/components/item/ActorsFormSection/ActorsFormSection'
import { MainFormSection } from '@/components/item/MainFormSection/MainFormSection' import { MainFormSection } from '@/components/item/MainFormSection/MainFormSection'
...@@ -65,7 +61,7 @@ export function ItemForm(props: ItemFormProps<ItemFormValues>): JSX.Element { ...@@ -65,7 +61,7 @@ export function ItemForm(props: ItemFormProps<ItemFormValues>): JSX.Element {
const toast = useToast() const toast = useToast()
const router = useRouter() const router = useRouter()
const auth = useAuth() const auth = useAuth()
const user = useGetLoggedInUser() const user = useCurrentUser()
const handleErrors = useErrorHandlers() const handleErrors = useErrorHandlers()
const validateCommonFormFields = useValidateCommonFormFields() const validateCommonFormFields = useValidateCommonFormFields()
const isAllowedToPublish = const isAllowedToPublish =
......
...@@ -3,7 +3,7 @@ import type { PropsWithChildren } from 'react' ...@@ -3,7 +3,7 @@ import type { PropsWithChildren } from 'react'
import { Fragment, useEffect } from 'react' import { Fragment, useEffect } from 'react'
import type { UserDto } from '@/api/sshoc' import type { UserDto } from '@/api/sshoc'
import { useGetLoggedInUser } from '@/api/sshoc' import { useCurrentUser } from '@/api/sshoc/client'
import { useAuth } from '@/modules/auth/AuthContext' import { useAuth } from '@/modules/auth/AuthContext'
export default function ProtectedScreen({ export default function ProtectedScreen({
...@@ -14,10 +14,7 @@ export default function ProtectedScreen({ ...@@ -14,10 +14,7 @@ export default function ProtectedScreen({
}>): JSX.Element | null { }>): JSX.Element | null {
const router = useRouter() const router = useRouter()
const { session } = useAuth() const { session } = useAuth()
const user = useGetLoggedInUser( const user = useCurrentUser()
{ enabled: session?.accessToken != null },
{ token: session?.accessToken },
)
useEffect(() => { useEffect(() => {
if (session === null || !hasAppropriateRole(roles, user.data)) { if (session === null || !hasAppropriateRole(roles, user.data)) {
......
import type { PropsWithChildren } from 'react' import type { PropsWithChildren } from 'react'
import { Fragment } from 'react' import { Fragment } from 'react'
import { useGetLoggedInUser } from '@/api/sshoc' import { useCurrentUser } from '@/api/sshoc/client'
import { useAuth } from '@/modules/auth/AuthContext' import { useAuth } from '@/modules/auth/AuthContext'
export default function ProtectedView({ export default function ProtectedView({
...@@ -11,10 +11,7 @@ export default function ProtectedView({ ...@@ -11,10 +11,7 @@ export default function ProtectedView({
roles?: Array<'contributor' | 'moderator' | 'administrator'> roles?: Array<'contributor' | 'moderator' | 'administrator'>
}>): JSX.Element | null { }>): JSX.Element | null {
const { session } = useAuth() const { session } = useAuth()
const user = useGetLoggedInUser( const user = useCurrentUser()
{ enabled: session?.accessToken != null },
{ token: session?.accessToken },
)
if (session === null) return null if (session === null) return null
......
...@@ -6,7 +6,8 @@ import { useRouter } from 'next/router' ...@@ -6,7 +6,8 @@ import { useRouter } from 'next/router'
import type { PropsWithChildren, Ref } from 'react' import type { PropsWithChildren, Ref } from 'react'
import { Fragment, useEffect, useState } from 'react' import { Fragment, useEffect, useState } from 'react'
import { useGetItemCategories, useGetLoggedInUser } from '@/api/sshoc' import { useGetItemCategories } from '@/api/sshoc'
import { useCurrentUser } from '@/api/sshoc/client'
import type { ItemCategory, ItemSearchQuery } from '@/api/sshoc/types' import type { ItemCategory, ItemSearchQuery } from '@/api/sshoc/types'
import { useAuth } from '@/modules/auth/AuthContext' import { useAuth } from '@/modules/auth/AuthContext'
import ProtectedView from '@/modules/auth/ProtectedView' import ProtectedView from '@/modules/auth/ProtectedView'
...@@ -23,7 +24,6 @@ import { getSingularItemCategoryLabel } from '@/utils/getSingularItemCategoryLab ...@@ -23,7 +24,6 @@ import { getSingularItemCategoryLabel } from '@/utils/getSingularItemCategoryLab
import type { UrlObject } from '@/utils/useActiveLink' import type { UrlObject } from '@/utils/useActiveLink'
import { useActiveLink } from '@/utils/useActiveLink' import { useActiveLink } from '@/utils/useActiveLink'
import { Svg as Logo } from '@@/assets/images/logo-with-text.svg' import { Svg as Logo } from '@@/assets/images/logo-with-text.svg'
/** /**
* Page header. * Page header.
*/ */
...@@ -243,19 +243,7 @@ function AuthButton() { ...@@ -243,19 +243,7 @@ function AuthButton() {
const router = useRouter() const router = useRouter()
const auth = useAuth() const auth = useAuth()
const { data: user } = useGetLoggedInUser( const { data: user } = useCurrentUser()
{
enabled: auth.session?.accessToken !== undefined,
/** immediately sign out in case of error */
retry: false,
onError() {
auth.signOut()
},
},
{
token: auth.session?.accessToken,
},
)
const [redirectPath, setRedirectPath] = useState(() => { const [redirectPath, setRedirectPath] = useState(() => {
const path = getRedirectPath(router.asPath) const path = getRedirectPath(router.asPath)
if (path === undefined) return undefined if (path === undefined) return undefined
......
import Link from 'next/link' import Link from 'next/link'
import { Fragment } from 'react' import { Fragment } from 'react'
import { useGetLoggedInUser } from '@/api/sshoc' import { useCurrentUser } from '@/api/sshoc/client'
import { Icon } from '@/elements/Icon/Icon' import { Icon } from '@/elements/Icon/Icon'
import { Svg as ActorsIcon } from '@/elements/icons/big/actors.svg' import { Svg as ActorsIcon } from '@/elements/icons/big/actors.svg'
import { Svg as ContributedItemsIcon } from '@/elements/icons/big/contributed-items.svg' import { Svg as ContributedItemsIcon } from '@/elements/icons/big/contributed-items.svg'
...@@ -57,7 +57,7 @@ const fields = [ ...@@ -57,7 +57,7 @@ const fields = [
* My account screen. * My account screen.
*/ */
export default function AccountScreen(): JSX.Element { export default function AccountScreen(): JSX.Element {
const user = useGetLoggedInUser() const user = useCurrentUser()
// just for typescript - user should always exist here // just for typescript - user should always exist here
if (user.data == null) return <div>User not found</div> if (user.data == null) return <div>User not found</div>
......
...@@ -6,7 +6,8 @@ import type { ChangeEvent, FormEvent, Key } from 'react' ...@@ -6,7 +6,8 @@ import type { ChangeEvent, FormEvent, Key } from 'react'
import { Fragment, useEffect, useState } from 'react' import { Fragment, useEffect, useState } from 'react'
import type { SearchItem, SearchItems } from '@/api/sshoc' import type { SearchItem, SearchItems } from '@/api/sshoc'
import { useGetLoggedInUser, useSearchItems } from '@/api/sshoc' import { useSearchItems } from '@/api/sshoc'
import { useCurrentUser } from '@/api/sshoc/client'
import type { ItemCategory, ItemSearchQuery } from '@/api/sshoc/types' import type { ItemCategory, ItemSearchQuery } from '@/api/sshoc/types'
import { ProgressSpinner } from '@/elements/ProgressSpinner/ProgressSpinner' import { ProgressSpinner } from '@/elements/ProgressSpinner/ProgressSpinner'
import { Select } from '@/elements/Select/Select' import { Select } from '@/elements/Select/Select'
...@@ -39,7 +40,7 @@ export default function ContributedItemsScreen(): JSX.Element { ...@@ -39,7 +40,7 @@ export default function ContributedItemsScreen(): JSX.Element {
const router = useRouter() const router = useRouter()
const query = sanitizeQuery(router.query) const query = sanitizeQuery(router.query)
const user = useGetLoggedInUser() const user = useCurrentUser()
const auth = useAuth() const auth = useAuth()
const handleErrors = useErrorHandlers() const handleErrors = useErrorHandlers()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment