Remove prompt from session data on deny

This commit is contained in:
Dominik Korsa 2021-01-18 21:09:18 +01:00
parent c4d3c4d003
commit 577e144d0b
No known key found for this signature in database
GPG key ID: 546F986F71A6FE6E

View file

@ -45,8 +45,10 @@ export default async function registerWebsiteApi(server: MyFastifyInstance): Pro
server.log.error(error); server.log.error(error);
throw server.httpErrors.internalServerError(); throw server.httpErrors.internalServerError();
} }
const prompt = getSessionData(request.session).prompts.get(request.query.prompt_id); const sessionData = getSessionData(request.session);
const prompt = sessionData.prompts.get(request.query.prompt_id);
if (!prompt) throw server.httpErrors.badRequest('Prompt data not found'); if (!prompt) throw server.httpErrors.badRequest('Prompt data not found');
await reply.redirect(`${prompt.redirectUri}?error=access_denied&error_description=${encodeURIComponent('User denied')}`); await reply.redirect(`${prompt.redirectUri}?error=access_denied&error_description=${encodeURIComponent('User denied')}`);
sessionData.prompts.delete(request.query.prompt_id);
}); });
} }