diff --git a/src/gui/src/UI/Dashboard/UIAccountDialogs.test.js b/src/gui/src/UI/Dashboard/UIAccountDialogs.test.js index 5883b309f..2e6509a68 100644 --- a/src/gui/src/UI/Dashboard/UIAccountDialogs.test.js +++ b/src/gui/src/UI/Dashboard/UIAccountDialogs.test.js @@ -226,7 +226,8 @@ describe('create API token', () => { describe('delete account', () => { it('asks a temporary account to type confirm', async () => { - window.user = { username: 'guest', is_temp: true }; + // What the server sends for a temporary account: no password, so `oidc_only` too. + window.user = { username: 'guest', is_temp: true, oidc_only: true }; fetch.mockResolvedValueOnce(reply(200, { success: true })); dialogs.openDeleteAccountDialog(); @@ -235,6 +236,7 @@ describe('delete account', () => { expect(fetch).not.toHaveBeenCalled(); await submitWith({ confirm: ' Confirm ' }); + expect(openRevalidatePopup).not.toHaveBeenCalled(); expect(bodyOf(0)).toEqual({}); expect(window.logout).toHaveBeenCalled(); }); diff --git a/src/gui/src/helpers/postUserProtected.js b/src/gui/src/helpers/postUserProtected.js index 7bdd99ca4..77fd79b75 100644 --- a/src/gui/src/helpers/postUserProtected.js +++ b/src/gui/src/helpers/postUserProtected.js @@ -76,7 +76,9 @@ export default async function postUserProtected (route, body, { password, onReva }; const revalidateFailed = () => ({ ok: false, data: {}, message: i18n('revalidate_failed', [], false) }); - if ( window.user?.oidc_only && ! password ) { + // A temporary account has no password either, but no linked provider: the + // routes that admit it (deleting it) need no proof of identity at all. + if ( window.user?.oidc_only && ! window.user.is_temp && ! password ) { if ( ! await revalidate() ) return revalidateFailed(); return settle(await post(body)); } diff --git a/src/gui/src/helpers/postUserProtected.test.js b/src/gui/src/helpers/postUserProtected.test.js index 6007250a2..b56d87e20 100644 --- a/src/gui/src/helpers/postUserProtected.test.js +++ b/src/gui/src/helpers/postUserProtected.test.js @@ -65,6 +65,18 @@ describe('postUserProtected', () => { expect(window.handleReauthRequired).toHaveBeenCalled(); }); + // The server reports `oidc_only` for any passwordless account, temporary ones included. + it('posts straight away for a temporary account, with no sign-in popup', async () => { + window.user = { oidc_only: true, is_temp: true }; + fetch.mockResolvedValueOnce(reply(200, { success: true })); + + const result = await postUserProtected('delete-own-user', {}); + + expect(openRevalidatePopup).not.toHaveBeenCalled(); + expect(bodyOf(0)).toEqual({}); + expect(result).toEqual({ ok: true, data: { success: true } }); + }); + it('signs a provider-only account in first and sends no password', async () => { window.user = { oidc_only: true, oidc_revalidate_url: 'https://puter.test/revalidate' }; const onRevalidate = vi.fn();