11import {
22 InteractionEvent ,
3- logtoCookieKey ,
4- logtoUiCookieGuard ,
53 MfaFactor ,
64 type RequestVerificationCodePayload ,
75 requestVerificationCodePayloadGuard ,
86 webAuthnAuthenticationOptionsGuard ,
97 webAuthnRegistrationOptionsGuard ,
108} from '@logto/schemas' ;
119import { getUserDisplayName } from '@logto/shared' ;
12- import { trySafe } from '@silverhand/essentials' ;
1310import { type Context } from 'koa' ;
1411import type Router from 'koa-router' ;
1512import { type IRouterParamContext } from 'koa-router' ;
@@ -25,6 +22,7 @@ import koaGuard from '#src/middleware/koa-guard.js';
2522import { type WithI18nContext } from '#src/middleware/koa-i18next.js' ;
2623import type TenantContext from '#src/tenants/TenantContext.js' ;
2724import assertThat from '#src/utils/assert-that.js' ;
25+ import { getLogtoCookie } from '#src/utils/cookie.js' ;
2826
2927import { parseUserProfile } from './actions/helpers.js' ;
3028import { interactionPrefix , verificationPath } from './const.js' ;
@@ -56,9 +54,7 @@ const buildVerificationCodeTemplateContext = async (
5654 }
5755
5856 // Safely get the orgId and appId context from cookie
59- const { appId : applicationId , organizationId } =
60- trySafe ( ( ) => logtoUiCookieGuard . parse ( JSON . parse ( ctx . cookies . get ( logtoCookieKey ) ?? '{}' ) ) ) ??
61- { } ;
57+ const { appId : applicationId , organizationId } = getLogtoCookie ( ctx ) ;
6258
6359 return passcodeLibrary . buildVerificationCodeContext ( {
6460 applicationId,
@@ -129,7 +125,13 @@ export default function additionalRoutes<T extends IRouterParamContext>(
129125 const messageContext = await buildVerificationCodeTemplateContext ( passcodes , ctx , guard . body ) ;
130126
131127 await sendVerificationCodeToIdentifier (
132- { event, ...guard . body , locale : ctx . locale , messageContext } ,
128+ {
129+ event,
130+ ...guard . body ,
131+ locale : ctx . locale ,
132+ uiLocales : getLogtoCookie ( ctx ) . uiLocales ,
133+ messageContext,
134+ } ,
133135 interactionDetails . jti ,
134136 createLog ,
135137 passcodes
0 commit comments