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

api.accounts.add does not add createdAt / signedUpAt timestamps #66

Open
rmehner opened this issue Apr 25, 2017 · 3 comments
Open

api.accounts.add does not add createdAt / signedUpAt timestamps #66

rmehner opened this issue Apr 25, 2017 · 3 comments

Comments

@rmehner
Copy link
Contributor

rmehner commented Apr 25, 2017

So according to https://github.com/hoodiehq/hoodie-account-server-api#apiaccountsadd calling api.accounts.add() like this:

api.accounts.add({
  username: 'pat',
  password: 'dontstopbelievin'
})

should create a user document with the properties signedUpAt and createdAt set to, well, the timestamp the doc was created. However, if you do it, they are not set.

The code just takes it from the passed properties and in the smoke test both properties are passed to the call, so that works.

So this is either:

  1. A legit bug and we should have default values for this, kinda like this (omitting tests for this):
diff --git a/lib/accounts/add.js b/lib/accounts/add.js
index 7fd89b4..a12720d 100644
--- a/lib/accounts/add.js
+++ b/lib/accounts/add.js
@@ -22,8 +22,8 @@ function addAccount (state, properties, options) {
     type: 'user',
     name: properties.username,
     password: properties.password,
-    createdAt: properties.createdAt,
-    signedUpAt: properties.signedUpAt,
+    createdAt: properties.createdAt || new Date(),
+    signedUpAt: properties.signedUpAt || new Date(),
     roles: [
       'id:' + accountId
     ].concat(properties.roles || [])
  1. A documentation issue where we might wanna extend the documentation with the other passable properties and explain what happens if you don't set them.
@janl
Copy link
Member

janl commented Apr 26, 2017

I think 1. is what we want here.

@gr2m
Copy link
Member

gr2m commented Apr 26, 2017

just fyi: the reason why we didn’t run into this with other project is that we currently pass createdAt / signedUpAt in @hoodie/account-server/routes/account.js.

We have split the routes and the api logic recently. I agree that at least the createdAt / updatedAt timestamps should be implemented in @hoodie/account-server-api. I think we can leave the .signedUpAt property in the routes handler, but that’s up for discussion

devguykyle pushed a commit to devguykyle/hoodie-account-server-api that referenced this issue Feb 8, 2018
@devguykyle
Copy link
Contributor

hey @gr2m just submitted a pull request from Fullstack LA, let me know if I need to make any changes.

Thanks!

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

No branches or pull requests

4 participants