Skip to content

fix: hide recovery link on refresh #263

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 2 commits into from
Jun 21, 2023
Merged
Changes from 1 commit
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
20 changes: 11 additions & 9 deletions src/routes/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,20 +135,22 @@ export const createLoginRoute: RouteCreator =
)
}

let initRecoveryUrl = ""
const initRegistrationUrl = getUrlForFlow(
kratosBrowserUrl,
"registration",
initRegistrationQuery,
)

const initRecoveryUrl = getUrlForFlow(
kratosBrowserUrl,
"recovery",
new URLSearchParams({
return_to:
(return_to && return_to.toString()) || flow.return_to || "",
}),
)
if (flow.refresh) {
initRecoveryUrl = getUrlForFlow(
kratosBrowserUrl,
"recovery",
new URLSearchParams({
return_to:
(return_to && return_to.toString()) || flow.return_to || "",
}),
)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

what happens if we don't refresh the flow at all and we are logging in for the first time? Then the recovery link will be gone right?

Copy link
Contributor

Choose a reason for hiding this comment

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

A better way might be to retrieve the session and then check if the user is already logged in. Based on that + refresh true we can hide the recovery link.

We will also need to omit the forgotPasswordURL property from additionalProps in the UserAuthCard function since we don't want to show the link at all.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ups, that should be inverted. Thanks!


res.render("login", {
nodes: flow.ui.nodes,
Expand Down