fix redirect
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import type { Route } from './+types'
|
||||
|
||||
import { redirect } from 'react-router'
|
||||
import { parse } from 'cookie'
|
||||
|
||||
export async function loader({ request, context }: Route.LoaderArgs) {
|
||||
@@ -19,7 +20,6 @@ export async function loader({ request, context }: Route.LoaderArgs) {
|
||||
})
|
||||
}
|
||||
|
||||
try {
|
||||
const r = await fetch(issuerUrl.toString(), {
|
||||
method: 'GET',
|
||||
headers: new Headers([
|
||||
@@ -36,20 +36,9 @@ export async function loader({ request, context }: Route.LoaderArgs) {
|
||||
})
|
||||
}
|
||||
|
||||
console.log('Authorize response', {
|
||||
json: await r.json(),
|
||||
headers: r.headers,
|
||||
status: r.status
|
||||
})
|
||||
|
||||
// Deny authorization if user lacks scopes requested by client
|
||||
if (r.status === 302) {
|
||||
return new Response(null, {
|
||||
status: r.status,
|
||||
headers: {
|
||||
Location: new URL('/deny', url.origin).toString()
|
||||
}
|
||||
})
|
||||
if (r.status === 403) {
|
||||
throw redirect(new URL('/deny', url.origin).toString())
|
||||
}
|
||||
|
||||
return new Response(null, {
|
||||
@@ -58,8 +47,4 @@ export async function loader({ request, context }: Route.LoaderArgs) {
|
||||
Location: loginUrl.toString()
|
||||
}
|
||||
})
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
return new Response(null, { status: 500 })
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user