Commit b02aa5fd authored by David Venhoek's avatar David Venhoek
Browse files

Further refinements to callback interface for changepin.

parent 5f4df375
......@@ -5,6 +5,7 @@ import (
"math/big"
"sort"
"time"
"strconv"
"github.com/credentials/go-go-gadget-paillier"
raven "github.com/getsentry/raven-go"
......@@ -82,8 +83,8 @@ type KeyshareHandler interface {
type ChangePinHandler interface {
ChangePinFailure(manager irma.SchemeManagerIdentifier, err error)
ChangePinSuccess(manager irma.SchemeManagerIdentifier)
ChangePinIncorrect(manager irma.SchemeManagerIdentifier, message string)
ChangePinBlocked(manager irma.SchemeManagerIdentifier, message string)
ChangePinIncorrect(manager irma.SchemeManagerIdentifier, attempts int)
ChangePinBlocked(manager irma.SchemeManagerIdentifier, timeout int)
}
// ClientHandler informs the user that the configuration or the list of attributes
......@@ -784,9 +785,17 @@ func (client *Client) keyshareChangePinWorker(managerID irma.SchemeManagerIdenti
case kssPinSuccess:
client.handler.ChangePinSuccess(managerID)
case kssPinFailure:
client.handler.ChangePinIncorrect(managerID, res.Message)
attempts, err := strconv.Atoi(res.Message)
if err != nil {
return err
}
client.handler.ChangePinIncorrect(managerID, attempts)
case kssPinError:
client.handler.ChangePinBlocked(managerID, res.Message)
timeout, err := strconv.Atoi(res.Message)
if err != nil {
return err
}
client.handler.ChangePinBlocked(managerID, timeout)
default:
return errors.New("Unknown keyshare response")
}
......
......@@ -55,7 +55,7 @@ func (i *TestClientHandler) ChangePinFailure(manager irma.SchemeManagerIdentifie
i.t.Fatal(err)
}
}
func (i *TestClientHandler) ChangePinIncorrect(manager irma.SchemeManagerIdentifier, message string) {
func (i *TestClientHandler) ChangePinIncorrect(manager irma.SchemeManagerIdentifier, attempts int) {
err := errors.New("incorrect pin")
select {
case i.c <- err: //nop
......@@ -63,7 +63,7 @@ func (i *TestClientHandler) ChangePinIncorrect(manager irma.SchemeManagerIdentif
i.t.Fatal(err)
}
}
func (i *TestClientHandler) ChangePinBlocked(manager irma.SchemeManagerIdentifier, message string) {
func (i *TestClientHandler) ChangePinBlocked(manager irma.SchemeManagerIdentifier, timeout int) {
err := errors.New("blocked account")
select {
case i.c <- err: //nop
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment