hoodiehq / hoodie-account-client

:dog: Account client API for the browser
https://hoodiehq.github.io/hoodie-account-client
Apache License 2.0
11 stars 24 forks source link

include profile in signIn / signOut / fetch response #107

Open gr2m opened 8 years ago

gr2m commented 8 years ago

If I want to get my profile data I have to do two calls

hoodie.account.signIn({username: 'foo', password: 'bar'})
.then(function () {
  return hoodie.account.profile.fetch()
})
.then(function () {
  // hoodie.account.profile.get() now returns locally cached profile data
})

Our JSON API supports the ?include parameter for all requests, so we could do two things

I would suggest to include option to signIn / signOut methods (we already do this for some of the admin API methods). The fetch method would need to send the ?include=account.profile param if it was called with something like account.fetch('profile.settings')

With that change all profile properties would be cached offline after signIn, so we can do hoodie.account.profile.get() later any time, even without an internet connection.

hoodie.account.signIn({username: 'foo', password: 'bar', include: 'profile'})
.then(function () {
  // hoodie.account.profile.get() now returns locally cached profile data
})
gr2m commented 8 years ago

As suggested in #111 I rather tend to always include the .profile property in all the things for sake of simplicity.