From e89c04aa26b8319dee798263046cd64db9d520bf Mon Sep 17 00:00:00 2001 From: Valentin Laurin Date: Thu, 6 Mar 2025 16:51:46 +0000 Subject: [PATCH] Use expired prompt config on failed refresh Failed refresh is a subset of expired access token which could possibly occur when both refresh and access tokens are expired; as such it makes sense to also use the `prompt.expired` config for this scenario. --- src/openid/prompt-supplier.js | 1 + src/openid/prompt-supplier.test.js | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/openid/prompt-supplier.js b/src/openid/prompt-supplier.js index 6af259b..7948a46 100644 --- a/src/openid/prompt-supplier.js +++ b/src/openid/prompt-supplier.js @@ -7,6 +7,7 @@ import {ERROR} from './authenticate.js'; export const defaultPromptSupplier = (config = {}) => (auth) => { switch (auth.error) { case ERROR.EXPIRED_TOKEN: + case ERROR.FAILED_REFRESH: return config.expired ?? undefined; default: return config.default ?? undefined; diff --git a/src/openid/prompt-supplier.test.js b/src/openid/prompt-supplier.test.js index a3f85e6..cf9b859 100644 --- a/src/openid/prompt-supplier.test.js +++ b/src/openid/prompt-supplier.test.js @@ -39,4 +39,25 @@ describe('defaultPromptSupplier', () => { expect(prompt).toBe('none'); }); }); + + describe('when auth error is `failed_refresh`', () => { + test('should return undefined when not set', async () => { + const config = { + default: 'login consent', + }; + const prompt = defaultPromptSupplier(config)({error: ERROR.FAILED_REFRESH}); + + expect(prompt).toBe(undefined); + }); + + test('should return expired prompt when set', async () => { + const config = { + default: 'login consent', + expired: 'none', + }; + const prompt = defaultPromptSupplier(config)({error: ERROR.FAILED_REFRESH}); + + expect(prompt).toBe('none'); + }); + }); });