Skip to content

Commit

Permalink
Avoid throwing error when user has no session
Browse files Browse the repository at this point in the history
Throwing error end in Sentry with a NotFound. What we want to do is
redirect user to /login
  • Loading branch information
andresgutgon committed Oct 22, 2024
1 parent cda5630 commit c719377
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import { QueryParams } from '@latitude-data/core/lib/pagination/buildPaginatedUr
import { computeDocumentLogsWithMetadataQuery } from '@latitude-data/core/services/documentLogs/computeDocumentLogsWithMetadata'
import { TableWithHeader } from '@latitude-data/web-ui'
import { findCommitCached } from '$/app/(private)/_data-access'
import { getCurrentUser } from '$/services/auth/getCurrentUser'
import { getSafeCurrentUser } from '$/services/auth/getCurrentUser'
import { ROUTES } from '$/services/routes'
import { redirect } from 'next/navigation'

import { DocumentLogs } from './_components/DocumentLogs'

Expand All @@ -13,7 +15,13 @@ export default async function DocumentPage({
params: { projectId: string; commitUuid: string; documentUuid: string }
searchParams: QueryParams
}) {
const { workspace } = await getCurrentUser()
const session = await getSafeCurrentUser()

if (!session) {
redirect(ROUTES.auth.login)
}

const { workspace } = session
const projectId = Number(params.projectId)
const commitUuid = params.commitUuid
const commit = await findCommitCached({ projectId, uuid: commitUuid })
Expand Down

0 comments on commit c719377

Please sign in to comment.