Skip to content

Commit

Permalink
fix: make user selection less strict since plugin identities can have…
Browse files Browse the repository at this point in the history
… native stanzas
  • Loading branch information
olastor committed May 3, 2024
1 parent c32d2b0 commit 294441d
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions pkg/sss/stanza.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ func (stanza *SSSStanza) Unwrap(identity *SSSIdentity) (data []byte, err error)
id.ShareId = shareIds[0]
} else {
selectedId, err := stanza.getUserSelectedShareId(i, func(shareId int) string {
if !slices.Contains(shareIds, shareId) {
// if there are no matching types, show all remaining ids
if len(shareIds) > 0 && !slices.Contains(shareIds, shareId) {
// plugins could handle different types of stanzas
return ""
}
Expand All @@ -215,10 +216,6 @@ func (stanza *SSSStanza) Unwrap(identity *SSSIdentity) (data []byte, err error)
return nil, err
}

if !slices.Contains(shareIds, selectedId) {
return nil, errors.New("Invalid id selected")
}

id.ShareId = selectedId
}
}
Expand Down Expand Up @@ -274,7 +271,7 @@ func (stanza *SSSStanza) Unwrap(identity *SSSIdentity) (data []byte, err error)
}

func (stanza *SSSStanza) getUserSelectedShareId(identityIndex int, printIdFn PrintIdFunction) (selectedId int, err error) {
message := fmt.Sprintf("\n\nEncountered multiple options for identity #%x.", identityIndex+1)
message := fmt.Sprintf("\n\nEncountered multiple options for identity #%d.", identityIndex+1)
message += "\n\n" + stanza.getTreeAsString(0, printIdFn) + "\n"

err = controller.SendCommand("msg", []byte(message), true)
Expand Down

0 comments on commit 294441d

Please sign in to comment.