Skip to content

Commit

Permalink
Use Assuan ErrCanceled when user cancels prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
eth-p committed Apr 23, 2023
1 parent 39effd0 commit e555687
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,21 @@ func passwordPrompt(s pinentry.Settings) ([]byte, error) {

func assuanError(err error) *common.Error {
var message = "Unspecified error"
var code common.ErrorCode = common.ErrCanceled

if err != nil {
message = err.Error()

if touchid.DidUserCancel(err) {
message = "User cancelled."
code = common.ErrCanceled
}
}

return &common.Error{
Src: common.ErrSrcPinentry,
SrcName: "pinentry",
Code: common.ErrCanceled,
Code: code,
Message: message,
}
}
Expand Down Expand Up @@ -378,7 +385,7 @@ func GetPIN(authFn AuthFunc, promptFn PromptFunc, logger *log.Logger) GetPinFunc
// User cancelled.
if touchid.DidUserCancel(err) {
logger.Printf("Authentication cancelled")
return "", nil
return "", assuanError(err)
}

// Other error.
Expand Down

0 comments on commit e555687

Please sign in to comment.