Skip to content

fix(auth): add ADMIN to Permission enum so admins can log in#984

Merged
lucca65 merged 1 commit into
masterfrom
fix/permission-enum-admin
Jun 17, 2026
Merged

fix(auth): add ADMIN to Permission enum so admins can log in#984
lucca65 merged 1 commit into
masterfrom
fix/permission-enum-admin

Conversation

@lucca65

@lucca65 lucca65 commented Jun 17, 2026

Copy link
Copy Markdown
Member

Problem

Admin users got "Authentication failed" at login even though the backend signIn succeeded (valid token returned). The generated Cambiatus.Enum.Permission (last regenerated 2022-07-13, #786) is missing the ADMIN value the backend now returns for admin roles. elm-graphql enum decoders Decode.fail on unknown values, so decoding the signIn response for an admin profile failed → RemoteData.Failureauth.failed.

Non-admin users are unaffected (no ADMIN permission in their payload) — which is why regular logins work after #982/#983 but admin logins didn't.

Fix

Add the Admin variant to the Permission enum (type, list, decoder, toString, fromString). Surgical unblock; yarn build compiles clean (nothing pattern-matches Permission exhaustively).

Follow-up

The generated schema is ~4 years stale. It should be fully regenerated (yarn generate-graphql) in a separate, reviewed change — there may be other drifted enums/fields.

🤖 Generated with Claude Code

The backend returns the `ADMIN` permission for admin roles, but the
generated Cambiatus.Enum.Permission (last regenerated 2022, #786) lacks
it. Its decoder fails on unknown values, so decoding the signIn response
for any admin user errored → elm-graphql returned RemoteData.Failure →
the UI showed "Authentication failed", even though the backend signIn
succeeded and returned a valid token. Non-admin users were unaffected.

Add the `Admin` variant (type, list, decoder, toString, fromString) as a
surgical unblock. The generated schema is years stale and should be
fully regenerated (yarn generate-graphql) in a separate, reviewed change.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@lucca65 lucca65 merged commit 034ffdf into master Jun 17, 2026
1 check passed
@lucca65 lucca65 deleted the fix/permission-enum-admin branch June 17, 2026 16:05
@netlify

netlify Bot commented Jun 17, 2026

Copy link
Copy Markdown

Deploy Preview for cambiatus-elm-book failed.

Name Link
🔨 Latest commit 7e1ca06
🔍 Latest deploy log https://app.netlify.com/projects/cambiatus-elm-book/deploys/6a32c5d7c8fe88000887d1ba

lucca65 added a commit that referenced this pull request Jun 17, 2026
The generated Cambiatus types were last refreshed in 2022 (#786) and had
drifted from the live backend — e.g. the Permission enum was missing
ADMIN, which broke signIn decoding for admin users (fixed surgically in
#984; this regen supersedes that with the generated version).

Regenerated with @dillonkearns/elm-graphql against the production graph
endpoint (app.cambiatus.io) because staging was unreachable at the time.
Changes are additive/compatible: new Object types (EncryptedMnemonicResult,
Passkey*), enum and field syncs. `yarn build` compiles clean and
elm-format validates.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant