Skip to content

Commit 7d0e864

Browse files
authored
feat: allow external partials on login & registration (#295)
1 parent 768fafd commit 7d0e864

File tree

5 files changed

+18
-2
lines changed

5 files changed

+18
-2
lines changed

src/pkg/route.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ export interface RouteOptions {
2020
faviconUrl?: string
2121
faviconType?: string
2222
theme?: Theme
23+
extraPartials?: {
24+
login: () => string
25+
registration: () => string
26+
}
2327
}
2428

2529
export type RouteOptionsCreator = (req: Request, res: Response) => RouteOptions

src/routes/login.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ export const createLoginRoute: RouteCreator =
3030
organization = "",
3131
login_challenge,
3232
} = req.query
33-
const { frontend, kratosBrowserUrl, logoUrl } = createHelpers(req, res)
33+
const { frontend, kratosBrowserUrl, logoUrl, extraPartials } =
34+
createHelpers(req, res)
3435

3536
const initFlowQuery = new URLSearchParams({
3637
aal: aal.toString(),
@@ -195,6 +196,8 @@ export const createLoginRoute: RouteCreator =
195196
},
196197
{ locale: res.locals.lang },
197198
),
199+
extraPartial: extraPartials?.login,
200+
extraContext: res.locals.extraContext,
198201
})
199202
})
200203
.catch(redirectOnSoftError(res, next, initFlowUrl))

src/routes/registration.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ export const createRegistrationRoute: RouteCreator =
2929
login_challenge,
3030
organization,
3131
} = req.query
32-
const { frontend, kratosBrowserUrl, logoUrl } = createHelpers(req, res)
32+
const { frontend, kratosBrowserUrl, logoUrl, extraPartials } =
33+
createHelpers(req, res)
3334

3435
const initFlowQuery = new URLSearchParams({
3536
...(return_to && { return_to: return_to.toString() }),
@@ -107,6 +108,8 @@ export const createRegistrationRoute: RouteCreator =
107108
},
108109
{ locale: res.locals.lang },
109110
),
111+
extraPartial: extraPartials?.registration,
112+
extraContext: res.locals.extraContext,
110113
})
111114
})
112115
.catch(redirectOnSoftError(res, next, initFlowUrl))

views/login.hbs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@
22
{{{card}}}
33

44
{{> webauthn_setup nodes=nodes webAuthnHandler=webAuthnHandler webauthnTriggerName="webauthn_login_trigger"}}
5+
{{#if extraPartial }}
6+
{{> (extraPartial) }}
7+
{{/if}}
58
</div>

views/registration.hbs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,7 @@
33
{{{card}}}
44

55
{{> webauthn_setup nodes=nodes webAuthnHandler=webAuthnHandler webauthnTriggerName="webauthn_register_trigger"}}
6+
{{#if extraPartial }}
7+
{{> (extraPartial) }}
8+
{{/if}}
69
</div>

0 commit comments

Comments
 (0)