diff options
author | Michael Muré <michael.mure@consensys.net> | 2019-02-01 12:22:00 +0100 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2019-03-01 22:40:22 +0100 |
commit | 56c6147eb6012252cf0b723b9eb6d1e841fc2f94 (patch) | |
tree | cce638adbf4a7d5b424fe9682cafc2fea5c64785 /identity/common.go | |
parent | 14b240af8fef269d2c1d5dde2fff192b656c50f3 (diff) | |
download | git-bug-56c6147eb6012252cf0b723b9eb6d1e841fc2f94.tar.gz |
identity: more refactoring progress
Diffstat (limited to 'identity/common.go')
-rw-r--r-- | identity/common.go | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/identity/common.go b/identity/common.go index 5301471a..00feaa2d 100644 --- a/identity/common.go +++ b/identity/common.go @@ -23,12 +23,13 @@ func (e ErrMultipleMatch) Error() string { // // If the given message has a "id" field, it's considered being a proper Identity. func UnmarshalJSON(raw json.RawMessage) (Interface, error) { - // First try to decode as a normal Identity - var i Identity + aux := &IdentityStub{} - err := json.Unmarshal(raw, &i) - if err == nil && i.id != "" { - return &i, nil + // First try to decode and load as a normal Identity + err := json.Unmarshal(raw, &aux) + if err == nil && aux.Id() != "" { + return aux, nil + // return identityResolver.ResolveIdentity(aux.Id) } // abort if we have an error other than the wrong type @@ -51,7 +52,3 @@ func UnmarshalJSON(raw json.RawMessage) (Interface, error) { return nil, fmt.Errorf("unknown identity type") } - -type Resolver interface { - ResolveIdentity(id string) (Interface, error) -} |