Skip to content

Commit

Permalink
fix: verification redirect base url (#254)
Browse files Browse the repository at this point in the history
  • Loading branch information
Benehiko authored Apr 3, 2023
1 parent 8c26266 commit 21fdefa
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 234 deletions.
231 changes: 0 additions & 231 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 16 additions & 3 deletions src/routes/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ import {
filterNodesByGroups,
isUiNodeInputAttributes,
} from "@ory/integrations/ui"
import path from "path"
import { URLSearchParams } from "url"
import {
RouteCreator,
RouteRegistrator,
defaultConfig,
getUrlForFlow,
isQuerySet,
logger,
redirectOnSoftError,
RouteCreator,
RouteRegistrator,
} from "../pkg"

export const createLoginRoute: RouteCreator =
Expand Down Expand Up @@ -78,8 +79,20 @@ export const createLoginRoute: RouteCreator =
flow: verificationFlow.id,
message: JSON.stringify(loginFlow.ui.messages),
})

const baseUrl = req.path.split("/")
// get rid of the last part of the path (e.g. "login")
baseUrl.pop()

// redirect to the verification page with the custom message
res.redirect("/verification?" + verificationParameters.toString())
res.redirect(
303,
// join the base url with the verification path
path.join(
req.baseUrl,
"verification?" + verificationParameters.toString(),
),
)
})
.catch(
redirectOnSoftError(
Expand Down

0 comments on commit 21fdefa

Please sign in to comment.