Skip to content

Commit

Permalink
Merge pull request #3646 from serlo/staging
Browse files Browse the repository at this point in the history
Deployment
  • Loading branch information
elbotho authored Apr 15, 2024
2 parents 06f239f + 5ea1397 commit 3d6f530
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions apps/web/src/pages/api/.ory/[...paths].ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,21 @@ export default async function customCreateApiHandler(
req: NextApiRequest,
res: NextApiResponse<string>
): Promise<void> {
if (req.method !== 'POST') console.log(req.url)
// injecting a function here to trigger an api call because
// unfortunately the kratos webhook ist not reliable atm.
// this is not used for the SSO flow (that still uses the kratos webhook)
function afterRegisterApiCall(body: string) {
if (
req.method !== 'POST' ||
!req.url?.startsWith('/api/.ory/self-service/registration?flow=') ||
!process.env.API_KRATOS_SECRET ||
process.env.NEXT_PUBLIC_ENV === 'production'
!process.env.API_KRATOS_SECRET
) {
return
}

const result = JSON.parse(body) as { identity: { id: string } }
const userId = result?.identity?.id

console.log({ userId })
console.log(result)

if (userId) {
void fetch(API_KRATOS_WEBHOOK_URL, {
method: 'POST',
Expand All @@ -71,8 +67,6 @@ export default async function customCreateApiHandler(
console.log(result.status)
console.log({ userId })
console.error(text)
} else {
console.log('jup, seems to work')
}
})
.catch((e) => {
Expand Down

0 comments on commit 3d6f530

Please sign in to comment.