Skip to content

Commit

Permalink
Use absolute urls in unilogin flow redirects
Browse files Browse the repository at this point in the history
`Response.redirect` needs absolute url in order to function correctly
  • Loading branch information
spaceo committed Nov 11, 2024
1 parent dab3e25 commit a2531db
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion app/auth/callback/unilogin/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { NextRequest } from "next/server"
import { IntrospectionResponse } from "openid-client"

import goConfig from "@/lib/config/config"
import { getUniloginClient, uniloginClientConfig } from "@/lib/session/oauth/uniloginClient"
import { getSession, setTokensOnSession } from "@/lib/session/session"
import { TTokenSet } from "@/lib/types/session"
Expand Down Expand Up @@ -52,6 +53,6 @@ export async function GET(request: NextRequest) {
} catch (error) {
console.error(error)
// TODO: Error page or redirect to login page.
return Response.redirect("/")
return Response.redirect(goConfig("app.url"))
}
}
3 changes: 2 additions & 1 deletion app/auth/logout/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { cookies } from "next/headers"
import { generators } from "openid-client"

import goConfig from "@/lib/config/config"
import { getUniloginClient, uniloginClientConfig } from "@/lib/session/oauth/uniloginClient"
import { getSession } from "@/lib/session/session"

Expand All @@ -10,7 +11,7 @@ export async function GET() {
const id_token = cookies().get("go-session:id_token")?.value
// TODO: Is this where we want to redirect to if id token cannot be resolved?
if (!id_token) {
return Response.redirect("/")
return Response.redirect(goConfig("app.url"))
}
const client = await getUniloginClient()
const endSession = client.endSessionUrl({
Expand Down

0 comments on commit a2531db

Please sign in to comment.