Bug
After deleting an account via /idp/account/delete and re-creating it with the same username, OIDC authorization fails with:
Authentication Error — server_error — oops! something went wrong
This is a recurring issue.
Cause
The error in the logs:
TypeError: Cannot read properties of undefined (reading 'getOIDCScopeEncountered')
at Check.oidc.oidc (oidc-provider/lib/helpers/interaction_policy/prompts/consent.js:29:50)
at oidc-provider/lib/actions/authorization/interactions.js:18:17
The flow:
- User deletes their account — account data and grants are removed
- User re-creates account with same username
- Client (e.g. mashlib-next) still has old session cookies/tokens and sends
prompt=consent to /idp/auth
loadExistingGrant() in provider.js checks ctx.oidc.session which is undefined (stale session)
- Returns
undefined — no grant object
- oidc-provider's consent check calls
getOIDCScopeEncountered() on the undefined grant → TypeError → 500
Possible fixes
- Clear OIDC session cookies on account deletion — when
/idp/account/delete runs, ensure session cookies are invalidated so the browser doesn't send stale tokens
- Guard in
loadExistingGrant — return a new grant (auto-approve) when session exists but old grant is gone, rather than returning undefined
- Error handler — catch this specific error and redirect to login instead of showing server_error
Steps to reproduce
- Register an account on a JSS instance
- Log in via OIDC from a client app
- Delete the account via
/idp/account/delete
- Re-register with the same username
- Try to log in again from the same browser → server_error
Bug
After deleting an account via
/idp/account/deleteand re-creating it with the same username, OIDC authorization fails with:This is a recurring issue.
Cause
The error in the logs:
The flow:
prompt=consentto/idp/authloadExistingGrant()inprovider.jschecksctx.oidc.sessionwhich is undefined (stale session)undefined— no grant objectgetOIDCScopeEncountered()on the undefined grant → TypeError → 500Possible fixes
/idp/account/deleteruns, ensure session cookies are invalidated so the browser doesn't send stale tokensloadExistingGrant— return a new grant (auto-approve) when session exists but old grant is gone, rather than returning undefinedSteps to reproduce
/idp/account/delete