From d184f984bda78c48e4b771b156a74fd70e1670d7 Mon Sep 17 00:00:00 2001 From: b5 Date: Fri, 30 Aug 2019 09:19:18 -0400 Subject: [PATCH] feat(registry): sync local profile details on successful signup --- lib/registry.go | 13 +++++++++++-- registry/profile.go | 16 ++++++++++++---- registry/regserver/handlers/profile.go | 3 ++- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/lib/registry.go b/lib/registry.go index 69952355f..f95377e13 100644 --- a/lib/registry.go +++ b/lib/registry.go @@ -34,6 +34,7 @@ func (m RegistryClientMethods) CreateProfile(p *RegistryProfile, ok *bool) (err return err } + log.Errorf("create profile response: %v", pro) *p = *pro cfg := m.configChanges(pro) @@ -52,6 +53,7 @@ func (m RegistryClientMethods) ProveProfileKey(p *RegistryProfile, ok *bool) err return err } + log.Errorf("prove profile response: %v", pro) *p = *pro cfg := m.configChanges(pro) @@ -61,7 +63,14 @@ func (m RegistryClientMethods) ProveProfileKey(p *RegistryProfile, ok *bool) err func (m RegistryClientMethods) configChanges(pro *registry.Profile) *config.Config { cfg := m.inst.cfg.Copy() cfg.Profile.Peername = pro.Username - // TODO (b5) - *all* profile details should come back from registry server - // set them here + cfg.Profile.Created = pro.Created + cfg.Profile.Email = pro.Email + cfg.Profile.Photo = pro.Photo + cfg.Profile.Thumb = pro.Thumb + cfg.Profile.Name = pro.Name + cfg.Profile.Description = pro.Description + cfg.Profile.HomeURL = pro.HomeURL + cfg.Profile.Twitter = pro.Twitter + return cfg } diff --git a/registry/profile.go b/registry/profile.go index 675a05fbf..4912dfdfb 100644 --- a/registry/profile.go +++ b/registry/profile.go @@ -10,11 +10,19 @@ import ( ) // Profile is a shorthand version of qri-io/qri/repo/profile.Profile +// TODO (b5) - this should be refactored to embed a config.Profile, +// add password & key fields type Profile struct { - Created time.Time - Username string - Email string - Password string `json:",omitempty"` + Created time.Time + Username string + Email string + Password string `json:",omitempty"` + Photo string + Thumb string + Name string + Description string + HomeURL string + Twitter string ProfileID string PublicKey string diff --git a/registry/regserver/handlers/profile.go b/registry/regserver/handlers/profile.go index 946a00b3e..8ae6d3eb9 100644 --- a/registry/regserver/handlers/profile.go +++ b/registry/regserver/handlers/profile.go @@ -31,7 +31,8 @@ func NewProfilesHandler(profiles registry.Profiles) http.HandlerFunc { for _, pro := range ps { profiles.Create(pro.Username, pro) } - fallthrough + + apiutil.WriteResponse(w, ps) case "GET": l, err := profiles.Len()