diff options
Diffstat (limited to 'identity/version.go')
-rw-r--r-- | identity/version.go | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/identity/version.go b/identity/version.go index f9c7b262..757b029f 100644 --- a/identity/version.go +++ b/identity/version.go @@ -24,7 +24,8 @@ type Version struct { unixTime int64 name string - email string // as defined in git, not for bridges + email string // as defined in git or from a bridge when importing the identity + login string // from a bridge when importing the identity avatarURL string // The set of keys valid at that time, from this version onward, until they get removed @@ -52,6 +53,7 @@ type VersionJSON struct { UnixTime int64 `json:"unix_time"` Name string `json:"name,omitempty"` Email string `json:"email,omitempty"` + Login string `json:"login,omitempty"` AvatarUrl string `json:"avatar_url,omitempty"` Keys []*Key `json:"pub_keys,omitempty"` Nonce []byte `json:"nonce,omitempty"` @@ -81,6 +83,7 @@ func (v *Version) MarshalJSON() ([]byte, error) { UnixTime: v.unixTime, Name: v.name, Email: v.email, + Login: v.login, AvatarUrl: v.avatarURL, Keys: v.keys, Nonce: v.nonce, @@ -103,6 +106,7 @@ func (v *Version) UnmarshalJSON(data []byte) error { v.unixTime = aux.UnixTime v.name = aux.Name v.email = aux.Email + v.login = aux.Login v.avatarURL = aux.AvatarUrl v.keys = aux.Keys v.nonce = aux.Nonce @@ -120,8 +124,8 @@ func (v *Version) Validate() error { return fmt.Errorf("lamport time not set") } - if text.Empty(v.name) { - return fmt.Errorf("name not set") + if text.Empty(v.name) && text.Empty(v.login) { + return fmt.Errorf("either name or login should be set") } if strings.Contains(v.name, "\n") { @@ -132,6 +136,14 @@ func (v *Version) Validate() error { return fmt.Errorf("name is not fully printable") } + if strings.Contains(v.login, "\n") { + return fmt.Errorf("login should be a single line") + } + + if !text.Safe(v.login) { + return fmt.Errorf("login is not fully printable") + } + if strings.Contains(v.email, "\n") { return fmt.Errorf("email should be a single line") } |