Skip to content

Commit

Permalink
Dont require profile to be loaded if necessary permissions are empty
Browse files Browse the repository at this point in the history
  • Loading branch information
henriquecbuss committed Feb 24, 2022
1 parent 267b4cd commit ed896c3
Showing 1 changed file with 57 additions and 41 deletions.
98 changes: 57 additions & 41 deletions src/elm/Session/LoggedIn.elm
Original file line number Diff line number Diff line change
Expand Up @@ -2513,29 +2513,37 @@ withPrivateKey :
-> UR.UpdateResult subModel subMsg (External subMsg)
-> UR.UpdateResult subModel subMsg (External subMsg)
withPrivateKey loggedIn necessaryPermissions subModel subMsg successfulUR =
case profile loggedIn of
Just validProfile ->
if hasPermissions validProfile necessaryPermissions then
if hasPrivateKey loggedIn then
successfulUR
let
actWithPrivateKey =
if hasPrivateKey loggedIn then
successfulUR

else
UR.init subModel
|> UR.addExt (RequiredPrivateKey subMsg)
in
if List.isEmpty necessaryPermissions then
actWithPrivateKey

else
case profile loggedIn of
Just validProfile ->
if hasPermissions validProfile necessaryPermissions then
actWithPrivateKey

else
UR.init subModel
|> UR.addExt (RequiredPrivateKey subMsg)
|> UR.addExt ShowInsufficientPermissionsModal

else
Nothing ->
UR.init subModel
|> UR.addExt ShowInsufficientPermissionsModal

Nothing ->
UR.init subModel
|> UR.logImpossible subMsg.successMsg
"Tried signing eos transaction, but profile wasn't loaded"
(Just loggedIn.accountName)
{ moduleName = "Session.LoggedIn"
, function = "withPrivateKey"
}
[]
|> UR.logImpossible subMsg.successMsg
"Tried signing eos transaction, but profile wasn't loaded"
(Just loggedIn.accountName)
{ moduleName = "Session.LoggedIn"
, function = "withPrivateKey"
}
[]


{-| Determines if a profile has a set of permissions
Expand All @@ -2552,32 +2560,40 @@ hasPermissions profile_ permissions =

withPrivateKeyInternal : Msg msg -> Model -> List Permission -> (Eos.PrivateKey -> UpdateResult msg) -> UpdateResult msg
withPrivateKeyInternal msg loggedIn necessaryPermissions successfulUR =
case profile loggedIn of
Just validProfile ->
if hasPermissions validProfile necessaryPermissions then
case maybePrivateKey loggedIn of
Just privateKey ->
successfulUR privateKey
let
actWithPrivateKey =
case maybePrivateKey loggedIn of
Just privateKey ->
successfulUR privateKey

Nothing ->
askedAuthentication loggedIn
|> UR.init
|> UR.addExt (AddAfterPrivateKeyCallback msg)
Nothing ->
askedAuthentication loggedIn
|> UR.init
|> UR.addExt (AddAfterPrivateKeyCallback msg)
in
if List.isEmpty necessaryPermissions then
actWithPrivateKey

else
{ loggedIn | showInsufficientPermissionsModal = True }
|> UR.init
else
case profile loggedIn of
Just validProfile ->
if hasPermissions validProfile necessaryPermissions then
actWithPrivateKey

_ ->
loggedIn
|> UR.init
|> UR.logImpossible msg
"Tried signing eos transaction internally, but profile wasn't loaded"
(Just loggedIn.accountName)
{ moduleName = "Session.LoggedIn"
, function = "withPrivateKeyInternal"
}
[]
else
{ loggedIn | showInsufficientPermissionsModal = True }
|> UR.init

_ ->
loggedIn
|> UR.init
|> UR.logImpossible msg
"Tried signing eos transaction internally, but profile wasn't loaded"
(Just loggedIn.accountName)
{ moduleName = "Session.LoggedIn"
, function = "withPrivateKeyInternal"
}
[]


isCommunityMember : Model -> Bool
Expand Down

0 comments on commit ed896c3

Please sign in to comment.