fix(auth): make things work
This commit is contained in:
@@ -1,22 +0,0 @@
|
||||
"use client"
|
||||
import { useParams } from "next/navigation"
|
||||
import { useEffect } from "react"
|
||||
|
||||
import { login } from "@/constants/routes/handleAuth"
|
||||
import { SESSION_EXPIRED } from "@/server/errors/trpc"
|
||||
|
||||
import type { ErrorPage } from "@/types/next/error"
|
||||
import type { LangParams } from "@/types/params"
|
||||
|
||||
export default function ProtectedError({ error }: ErrorPage) {
|
||||
const params = useParams<LangParams>()
|
||||
|
||||
useEffect(() => {
|
||||
if (error.message === SESSION_EXPIRED) {
|
||||
const loginUrl = login[params.lang]
|
||||
window.location.assign(loginUrl)
|
||||
}
|
||||
}, [error.message, params.lang])
|
||||
|
||||
return null
|
||||
}
|
||||
@@ -1,23 +1,34 @@
|
||||
"use client" // Error components must be Client Components
|
||||
|
||||
import { usePathname } from "next/navigation"
|
||||
import { useParams, usePathname } from "next/navigation"
|
||||
import { useEffect } from "react"
|
||||
|
||||
import { findLang } from "@/constants/languages"
|
||||
import { login } from "@/constants/routes/handleAuth"
|
||||
import { SESSION_EXPIRED } from "@/server/errors/trpc"
|
||||
|
||||
import { firaMono, firaSans } from "@/app/[lang]/(live)/fonts"
|
||||
|
||||
import styles from "./error.module.css"
|
||||
|
||||
import { LangParams } from "@/types/params"
|
||||
|
||||
export default function Error({
|
||||
error,
|
||||
}: {
|
||||
error: Error & { digest?: string }
|
||||
}) {
|
||||
const params = useParams<LangParams>()
|
||||
|
||||
useEffect(() => {
|
||||
// Log the error to an error reporting service
|
||||
console.error(error)
|
||||
}, [error])
|
||||
|
||||
if (error.message === SESSION_EXPIRED) {
|
||||
const loginUrl = login[params.lang]
|
||||
window.location.assign(loginUrl)
|
||||
}
|
||||
}, [error, params.lang])
|
||||
|
||||
const pathname = usePathname()
|
||||
const lang = findLang(pathname)
|
||||
|
||||
Reference in New Issue
Block a user