Skip to content
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

feat: allow external partials on login & registration #295

Merged
merged 2 commits into from
Sep 19, 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
4 changes: 4 additions & 0 deletions src/pkg/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ export interface RouteOptions {
faviconUrl?: string
faviconType?: string
theme?: Theme
extraPartials?: {
login: () => string
registration: () => string
}
}

export type RouteOptionsCreator = (req: Request, res: Response) => RouteOptions
Expand Down
5 changes: 4 additions & 1 deletion src/routes/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ export const createLoginRoute: RouteCreator =
organization = "",
login_challenge,
} = req.query
const { frontend, kratosBrowserUrl, logoUrl } = createHelpers(req, res)
const { frontend, kratosBrowserUrl, logoUrl, extraPartials } =
createHelpers(req, res)

const initFlowQuery = new URLSearchParams({
aal: aal.toString(),
Expand Down Expand Up @@ -195,6 +196,8 @@ export const createLoginRoute: RouteCreator =
},
{ locale: res.locals.lang },
),
extraPartial: extraPartials?.login,
extraContext: res.locals.extraContext,
})
})
.catch(redirectOnSoftError(res, next, initFlowUrl))
Expand Down
5 changes: 4 additions & 1 deletion src/routes/registration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ export const createRegistrationRoute: RouteCreator =
login_challenge,
organization,
} = req.query
const { frontend, kratosBrowserUrl, logoUrl } = createHelpers(req, res)
const { frontend, kratosBrowserUrl, logoUrl, extraPartials } =
createHelpers(req, res)

const initFlowQuery = new URLSearchParams({
...(return_to && { return_to: return_to.toString() }),
Expand Down Expand Up @@ -107,6 +108,8 @@ export const createRegistrationRoute: RouteCreator =
},
{ locale: res.locals.lang },
),
extraPartial: extraPartials?.registration,
extraContext: res.locals.extraContext,
})
})
.catch(redirectOnSoftError(res, next, initFlowUrl))
Expand Down
3 changes: 3 additions & 0 deletions views/login.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
{{{card}}}

{{> webauthn_setup nodes=nodes webAuthnHandler=webAuthnHandler webauthnTriggerName="webauthn_login_trigger"}}
{{#if extraPartial }}
{{> (extraPartial) }}
{{/if}}
</div>
3 changes: 3 additions & 0 deletions views/registration.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
{{{card}}}

{{> webauthn_setup nodes=nodes webAuthnHandler=webAuthnHandler webauthnTriggerName="webauthn_register_trigger"}}
{{#if extraPartial }}
{{> (extraPartial) }}
{{/if}}
</div>
Loading