fix: Allow clients to be remembered in the SessionHttpHandler

This commit is contained in:
Joachim Van Herwegen
2021-08-17 15:55:03 +02:00
parent 1173f98b5d
commit 47b3a2d77f
7 changed files with 28 additions and 13 deletions

View File

@@ -1,18 +1,21 @@
import { NotImplementedHttpError } from '../../util/errors/NotImplementedHttpError';
import { InteractionHandler } from './email-password/handler/InteractionHandler';
import type { InteractionCompleteResult, InteractionHandlerInput } from './email-password/handler/InteractionHandler';
import { getFormDataRequestBody } from './util/FormDataUtil';
/**
* Simple InteractionHttpHandler that sends the session accountId to the InteractionCompleter as webId.
*/
export class SessionHttpHandler extends InteractionHandler {
public async handle({ oidcInteraction }: InteractionHandlerInput): Promise<InteractionCompleteResult> {
public async handle({ request, oidcInteraction }: InteractionHandlerInput): Promise<InteractionCompleteResult> {
if (!oidcInteraction?.session) {
throw new NotImplementedHttpError('Only interactions with a valid session are supported.');
}
const { remember } = await getFormDataRequestBody(request);
return {
type: 'complete',
details: { webId: oidcInteraction.session.accountId },
details: { webId: oidcInteraction.session.accountId, shouldRemember: Boolean(remember) },
};
}
}