This is a set of ideas for how an forms2accounts module could work that uses accountdown and is meant to facilitate the creation and updates of accounts from a form. Primary usage would be on the server.
or some similar package name.
forms2accounts
is available, though
server.accountdown
: an accountdown instance for updating and storing accountsaccount
: An associative array defining the schema of the accounts. Each field is mapped to either a boolean describing whether the field is required, or a default value when the field is not provided. If the default value is a boolean, then it is listed in quotes. Here is an example that uses the accountdown-basic module as the credentials plugin while supplying a customizedvalue
attribute with three required fields (email
,username
, anduuid
), one non-required field (favorite-food
) and two optional fields with default values (admin
andcolor
):
var account = {
login: {
basic: {
username: true,
password: true
}
},
value: {
admin: 'false',
color: randomColor(),
favorite-food: false,
email: true,
username: true,
uuid: true
}
};
options
: TBD
req
,res
: Parses thereq
andres
objects using the body'sbody/form
module, and creates an account
Internally, all accounts are created with the key generated from uuid, version 1.
callback
provideserror
argument
-
req
,res
: Parses thereq
andres
objects using the body'sbody/form
module, and creates an account -
callback
provides anerror
argument.
uuid
: string key that identifies the account that will be removed
Internally, this function is just a convenience wrapper for the accountdown.remove
function
callback
provides anerror
argument.
Returns a stream of all accounts
Internally, this function is just a convenience wrapper for the accountdown.list
function
uuid
: string key that identifies the account that will be retrieved
Internally, this function is just a convenience wrapper for the accountdown.get
function
callback
provideserror
argument
So it seems like the usage example would be something like this:
A file that defines some routes:
It would be cool if the callback was optional. Maybe the error response could be handled in some default way, and we pass the callback only if we need to do something special