From 7e1ca06605ade13b7159afc14dfbd81315c6559e Mon Sep 17 00:00:00 2001 From: Julien Lucca Date: Wed, 17 Jun 2026 18:05:20 +0200 Subject: [PATCH] fix(auth): add ADMIN to Permission enum so admins can log in MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/elm/Cambiatus/Enum/Permission.elm | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/elm/Cambiatus/Enum/Permission.elm b/src/elm/Cambiatus/Enum/Permission.elm index 42f8aec2b..792e4c72e 100644 --- a/src/elm/Cambiatus/Enum/Permission.elm +++ b/src/elm/Cambiatus/Enum/Permission.elm @@ -9,6 +9,7 @@ import Json.Decode as Decode exposing (Decoder) {-| Permissions a role can have + - Admin - Role permission that grants full administrative access to the community - Award - Role permission that allows to award rewards on community actions - Claim - Role permission that allows to claim actions - Invite - Role permission that allows to create invitations to the community @@ -19,7 +20,8 @@ import Json.Decode as Decode exposing (Decoder) -} type Permission - = Award + = Admin + | Award | Claim | Invite | Order @@ -30,7 +32,7 @@ type Permission list : List Permission list = - [ Award, Claim, Invite, Order, Sell, Transfer, Verify ] + [ Admin, Award, Claim, Invite, Order, Sell, Transfer, Verify ] decoder : Decoder Permission @@ -39,6 +41,9 @@ decoder = |> Decode.andThen (\string -> case string of + "ADMIN" -> + Decode.succeed Admin + "AWARD" -> Decode.succeed Award @@ -70,6 +75,9 @@ decoder = toString : Permission -> String toString enum = case enum of + Admin -> + "ADMIN" + Award -> "AWARD" @@ -106,6 +114,9 @@ This can be useful for generating Strings to use for