Skip to content

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

Open
@rmehner

Description

@rmehner

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions