Skip to content

Commit

Permalink
feat(registry): sync local profile details on successful signup
Browse files Browse the repository at this point in the history
  • Loading branch information
b5 committed Aug 30, 2019
1 parent d88c2b6 commit d184f98
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
13 changes: 11 additions & 2 deletions lib/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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
}
16 changes: 12 additions & 4 deletions registry/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion registry/regserver/handlers/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit d184f98

Please sign in to comment.