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

Added custom error message for KeyshareUnenrolled

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