fix: redirect users to /refresh on unauth and mod webview links
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { headers } from "next/headers"
|
||||
import { cookies, headers } from "next/headers"
|
||||
|
||||
import { Lang } from "@/constants/languages"
|
||||
|
||||
@@ -10,6 +10,7 @@ type CreateContextOptions = {
|
||||
pathname: string
|
||||
uid?: string | null
|
||||
url: string
|
||||
webToken: string | undefined
|
||||
}
|
||||
|
||||
/** Use this helper for:
|
||||
@@ -23,6 +24,7 @@ export function createContextInner(opts: CreateContextOptions) {
|
||||
pathname: opts.pathname,
|
||||
uid: opts.uid,
|
||||
url: opts.url,
|
||||
webToken: opts.webToken,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,20 +35,8 @@ export function createContextInner(opts: CreateContextOptions) {
|
||||
export function createContext() {
|
||||
const h = headers()
|
||||
|
||||
// const cookie = cookies()
|
||||
// const webviewTokenCookie = cookie.get("webviewToken")
|
||||
|
||||
// if (webviewTokenCookie) {
|
||||
// // since the token exists, this is a subsequent visit
|
||||
// // we're done, allow it
|
||||
// return createContextInner({
|
||||
// session: {
|
||||
// token: { access_token: webviewTokenCookie.value },
|
||||
// },
|
||||
// })
|
||||
// }
|
||||
|
||||
// const session = await auth()
|
||||
const cookie = cookies()
|
||||
const webviewTokenCookie = cookie.get("webviewToken")
|
||||
|
||||
return createContextInner({
|
||||
auth,
|
||||
@@ -54,6 +44,7 @@ export function createContext() {
|
||||
pathname: h.get("x-pathname")!,
|
||||
uid: h.get("x-uid"),
|
||||
url: h.get("x-url")!,
|
||||
webToken: webviewTokenCookie?.value,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user