Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proof of concept for account profiles. #158

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open

Proof of concept for account profiles. #158

wants to merge 12 commits into from

Conversation

jameswestnz
Copy link

@jameswestnz jameswestnz commented Jun 2, 2016

Some notes on this PR:

  • Tests have not yet been completed.
  • I have assumed that profiles will be a permanent part of all account requests. I.e. this information is always included in get requests.
  • Have only focussed on initial sign-up and session/account retrieval. So currently no profile requests have been dealt to.

To do:

More than happy for someone to add to this PR ;)

roles: findCustomRoles(roles)
}

if (options.includeProfile) {
account.profile = doc.profile
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would leave that in, but replace account.profile = doc.profile with account.profile = doc.profile || {}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Restored here: cb223fa

@gr2m
Copy link
Member

gr2m commented Jun 5, 2016

besides updating the PUT /session/account route, we should also update PATCH /session/account, and we must make sure to update docs and the JSON API spec: https://github.com/hoodiehq/account-json-api.

Let’s get this ready first, then move on to hoodiehq/hoodie-account-client#98

type: 'profile',
attributes: {
id: 'userid123-profile',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you move the id? It should be next to type where it was, it’s part of the JSON API spec

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of those "it made it pass the test" scenarios... I've instead fixed it properly since!

@jameswestnz
Copy link
Author

jameswestnz commented Jun 15, 2016

Hey @gr2m - keen on your thoughts on latest commits. We've now got tests passing, and updates via PATCH are working.

One thing I noticed is that the original code assumed the profile id (i.e. userid123-profile) was sent as an attribute along with the data like so:

{
  "id": "account123-profile",
  "fullname": "Dr Pat Hook",
  "address": {
    "city": "Berlin",
    "street": "Adalberststraße 4a"
  }
}

Is this correct? The tests that were built (although weren't being used due to not having any profile data in tests) assumed that the id would be one level up in the request - looking something like this:

{
  "id": "account123-profile",
  "attributes": {
    "fullname": "Dr Pat Hook",
    "address": {
      "city": "Berlin",
      "street": "Adalberststraße 4a"
    }
  }
}

If the latter is intended, I'm guessing it's something we need to solve over in @hoodie/account-client, as this would be at the request level. It would also mean the docs for this feature need a tweak here: https://github.com/hoodiehq/hoodie-account-client#accountprofileupdate

@jameswestnz
Copy link
Author

@gr2m in regards to my last comment, I think I've tidied this up. The latter (in my mind) was correct, and was how the client was actually operating - we just had some inconsistent code/docs which I added into the mix. Seems to be correct now?

var id = request.payload.data.id
var query = request.query
accounts.add({
username: username,
password: password,
include: query.include,
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gr2m is this correct? Or the below? My understanding is that this should be an option, not a property?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you got it right, good catch

}
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants