mirror of
https://github.com/CommunitySolidServer/CommunitySolidServer.git
synced 2024-10-03 14:55:10 +00:00
fix: Allow clients to be remembered in the SessionHttpHandler
This commit is contained in:
@@ -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) },
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user