Skip to content

Parse new isSuperAdmin on session #64

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/UnisonShare/Account.elm
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type alias Account a =
, pronouns : Maybe String
, completedTours : List Tour
, organizationMemberships : List OrganizationMembership
, isSuperAdmin : Bool
}


Expand Down Expand Up @@ -88,18 +89,20 @@ isProjectOwner projectRef account =
decodeSummary : Decode.Decoder AccountSummary
decodeSummary =
let
makeSummary handle name_ avatarUrl completedTours organizationMemberships =
makeSummary handle name_ avatarUrl completedTours organizationMemberships isSuperAdmin =
{ handle = handle
, name = name_
, avatarUrl = avatarUrl
, pronouns = Nothing
, completedTours = Maybe.withDefault [] completedTours
, organizationMemberships = organizationMemberships
, isSuperAdmin = isSuperAdmin
}
in
Decode.map5 makeSummary
Decode.map6 makeSummary
(field "handle" UserHandle.decodeUnprefixed)
(maybe (field "name" string))
(maybe (field "avatarUrl" decodeUrl))
(maybe (field "completedTours" (Decode.list Tour.decode)))
(field "organizationMemberships" (Decode.list (Decode.map OrganizationMembership UserHandle.decodeUnprefixed)))
(field "isSuperAdmin" Decode.bool)
2 changes: 1 addition & 1 deletion src/UnisonShare/Page/ErrorPage.elm
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ view : Session -> Http.Error -> String -> String -> PageLayout msg
view session error entityName className =
let
errorDetails =
if Session.isUnisonMember session then
if Session.isSuperAdmin session then
details [] [ summary [] [ text "Error Details" ], div [] [ text (Util.httpErrorToString error) ] ]

else
Expand Down
11 changes: 11 additions & 0 deletions src/UnisonShare/Session.elm
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module UnisonShare.Session exposing
, isOrganizationMember
, isProjectOwner
, isSignedIn
, isSuperAdmin
, isUnisonMember
)

Expand Down Expand Up @@ -41,6 +42,16 @@ isSignedIn session =
True


isSuperAdmin : Session -> Bool
isSuperAdmin session =
case session of
Anonymous ->
False

SignedIn account_ ->
account_.isSuperAdmin


isProjectOwner : ProjectRef -> Session -> Bool
isProjectOwner projectRef session =
isHandle (ProjectRef.handle projectRef) session
Expand Down
Loading