Skip to content

Commit

Permalink
fix: handle-session-exception (#507)
Browse files Browse the repository at this point in the history
  • Loading branch information
caprolactam authored Oct 31, 2023
1 parent 44d52a4 commit c88db93
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import {
import { Icon, href as iconsHref } from './components/ui/icon.tsx'
import fontStyleSheetUrl from './styles/font.css'
import tailwindStyleSheetUrl from './styles/tailwind.css'
import { authenticator, getUserId } from './utils/auth.server.ts'
import { getUserId, logout } from './utils/auth.server.ts'
import { ClientHintCheck, getHints, useHints } from './utils/client-hints.tsx'
import { getConfetti } from './utils/confetti.server.ts'
import { csrf } from './utils/csrf.server.ts'
Expand Down Expand Up @@ -130,7 +130,7 @@ export async function loader({ request }: DataFunctionArgs) {
console.info('something weird happened')
// something weird happened... The user is authenticated but we can't find
// them in the database. Maybe they were deleted? Let's log them out.
await authenticator.logout(request, { redirectTo: '/' })
await logout({ request, redirectTo: '/' })
}
const { toast, headers: toastHeaders } = await getToast(request)
const { confettiId, headers: confettiHeaders } = getConfetti(request)
Expand Down
4 changes: 2 additions & 2 deletions app/routes/me.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { redirect, type DataFunctionArgs } from '@remix-run/node'
import { authenticator, requireUserId } from '#app/utils/auth.server.ts'
import { requireUserId, logout } from '#app/utils/auth.server.ts'
import { prisma } from '#app/utils/db.server.ts'

export async function loader({ request }: DataFunctionArgs) {
Expand All @@ -11,7 +11,7 @@ export async function loader({ request }: DataFunctionArgs) {
['redirectTo', `${requestUrl.pathname}${requestUrl.search}`],
])
const redirectTo = `/login?${loginParams}`
await authenticator.logout(request, { redirectTo })
await logout({ request, redirectTo })
return redirect(redirectTo)
}
return redirect(`/users/${user.username}`)
Expand Down

0 comments on commit c88db93

Please sign in to comment.