Commit 39dff3e6 authored by Ivar Derksen's avatar Ivar Derksen Committed by Sietse Ringers

Added custom error message for KeyshareUnenrolled

parent 0f1f2b70
......@@ -533,16 +533,16 @@ func (session *session) getProof() (interface{}, error) {
// checkKeyshareEnrollment checks if we are enrolled into all involved keyshare servers,
// and aborts the session if not
func (session *session) checkKeyshareEnrollment() error {
func (session *session) checkKeyshareEnrollment() bool {
for id := range session.request.Identifiers().SchemeManagers {
distributed := session.client.Configuration.SchemeManagers[id].Distributed()
_, enrolled := session.client.keyshareServers[id]
if distributed && !enrolled {
session.Handler.KeyshareEnrollmentMissing(id)
return &irma.SessionError{ErrorType: irma.ErrorKeyshare, Handled: true}
return false
}
}
return nil
return true
}
func (session *session) checkAndUpdateConfiguration() error {
......@@ -561,8 +561,8 @@ func (session *session) checkAndUpdateConfiguration() error {
}
// Check if we are enrolled into all involved keyshare servers
if err = session.checkKeyshareEnrollment(); err != nil {
return err
if !session.checkKeyshareEnrollment() {
return &irma.SessionError{ErrorType: irma.ErrorKeyshareUnenrolled}
}
if err = session.request.Disclosure().Disclose.Validate(session.client.Configuration); err != nil {
......@@ -643,7 +643,7 @@ func (session *session) delete() bool {
}
func (session *session) fail(err *irma.SessionError) {
if session.delete() && !err.Handled {
if session.delete() && err.ErrorType != irma.ErrorKeyshareUnenrolled {
err.Err = errors.Wrap(err.Err, 0)
session.Handler.Failure(err)
}
......
......@@ -104,7 +104,6 @@ type SessionError struct {
Info string
RemoteError *RemoteError
RemoteStatus int
Handled bool // set to true when error status is already communicated to session handler
}
// RemoteError is an error message returned by the API server on errors.
......@@ -186,6 +185,8 @@ const (
ErrorSerialization = ErrorType("serialization")
// Error in keyshare protocol
ErrorKeyshare = ErrorType("keyshare")
// The user is not enrolled at one of the keyshare servers needed for the request
ErrorKeyshareUnenrolled = ErrorType("keyshareUnenrolled")
// API server error
ErrorApi = ErrorType("api")
// Server returned unexpected or malformed response
......
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