Unverified Commit 6ca9a8fa authored by confiks's avatar confiks Committed by GitHub
Browse files

Merge pull request #15 from privacybydesign/david-pinchange

Further refined feedback functions for pinchange request.
parents ede8e739 4d97255d
......@@ -5,6 +5,7 @@ import (
"math/big"
"sort"
"time"
"strconv"
"github.com/credentials/go-go-gadget-paillier"
raven "github.com/getsentry/raven-go"
......@@ -82,7 +83,8 @@ type KeyshareHandler interface {
type ChangePinHandler interface {
ChangePinFailure(manager irma.SchemeManagerIdentifier, err error)
ChangePinSuccess(manager irma.SchemeManagerIdentifier)
ChangePinIncorrect(manager irma.SchemeManagerIdentifier)
ChangePinIncorrect(manager irma.SchemeManagerIdentifier, attempts int)
ChangePinBlocked(manager irma.SchemeManagerIdentifier, timeout int)
}
// ClientHandler informs the user that the configuration or the list of attributes
......@@ -781,10 +783,23 @@ func (client *Client) keyshareChangePinWorker(managerID irma.SchemeManagerIdenti
return err
}
if res.Status != kssPinSuccess {
client.handler.ChangePinIncorrect(managerID)
} else {
switch res.Status {
case kssPinSuccess:
client.handler.ChangePinSuccess(managerID)
case kssPinFailure:
attempts, err := strconv.Atoi(res.Message)
if err != nil {
return err
}
client.handler.ChangePinIncorrect(managerID, attempts)
case kssPinError:
timeout, err := strconv.Atoi(res.Message)
if err != nil {
return err
}
client.handler.ChangePinBlocked(managerID, timeout)
default:
return errors.New("Unknown keyshare response")
}
return nil
......
......@@ -55,7 +55,7 @@ func (i *TestClientHandler) ChangePinFailure(manager irma.SchemeManagerIdentifie
i.t.Fatal(err)
}
}
func (i *TestClientHandler) ChangePinIncorrect(manager irma.SchemeManagerIdentifier) {
func (i *TestClientHandler) ChangePinIncorrect(manager irma.SchemeManagerIdentifier, attempts int) {
err := errors.New("incorrect pin")
select {
case i.c <- err: //nop
......@@ -63,6 +63,14 @@ func (i *TestClientHandler) ChangePinIncorrect(manager irma.SchemeManagerIdentif
i.t.Fatal(err)
}
}
func (i *TestClientHandler) ChangePinBlocked(manager irma.SchemeManagerIdentifier, timeout int) {
err := errors.New("blocked account")
select {
case i.c <- err: //nop
default:
i.t.Fatal(err)
}
}
func parseStorage(t *testing.T) *Client {
require.NoError(t, fs.CopyDirectory("../testdata/teststorage", "../testdata/storage/test"))
......
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