mirror of
https://github.com/pocket-id/pocket-id.git
synced 2026-09-17 08:29:04 +02:00
fix: show more user friendly error page for authorize interaction failures
This commit is contained in:
@@ -1,16 +1,23 @@
|
||||
import OidcService from '$lib/services/oidc-service';
|
||||
import { error } from '@sveltejs/kit';
|
||||
import { getAxiosErrorMessage } from '$lib/utils/error-util';
|
||||
import { redirect } from '@sveltejs/kit';
|
||||
import type { PageLoad } from './$types';
|
||||
|
||||
export const load: PageLoad = async ({ url }) => {
|
||||
const interactionSessionId = url.searchParams.get('interaction');
|
||||
if (!interactionSessionId) {
|
||||
error(400, 'Missing authorize interaction');
|
||||
return redirectToError('Missing authorize interaction');
|
||||
}
|
||||
|
||||
const oidcService = new OidcService();
|
||||
const interactionSession = await oidcService.getAuthorizeInteraction(interactionSessionId);
|
||||
const interactionSession = await oidcService
|
||||
.getAuthorizeInteraction(interactionSessionId)
|
||||
.catch((e) => redirectToError(getAxiosErrorMessage(e)));
|
||||
return {
|
||||
interactionSession
|
||||
};
|
||||
};
|
||||
|
||||
function redirectToError(errorMessage: string): never {
|
||||
redirect(302, `/interaction/error?${new URLSearchParams({ error: errorMessage }).toString()}`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user