Skip to content

fix: verification redirect base url #254

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
Comment on lines +83 to +85
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is maybe a bit overkill and just a simple res.redirect("verification") might've been suffice. But I added this in case the application was hosted with a base URL added to the router.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you could add that comment to the code as well. This will lead to confusion down the future.


// 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