Accounts

These methods are used to manage accounts on your system.

createAccount(strategy, account, password, who, done)

strategy

account

password

who

function(err, id){}

Create a new account using the strategy name provided. The strategy will select the middleware required. When no middleware matches the create account event will be emitted. The account argument should be the name of the account. The password should be in plain text. This module will hash it by default. The who argument is used for accounting records. You can set this to the account name of who or what is creating the account.

The last item is a callback that can be called to notify you if the middleware succeeded. The id field should match the accounts new id.

Event: 'create account'

account

password

function(err, id) {}

Emitted after the createAccount method is called if none of the configured middleware can handle the requested. The password object will be hashed automatically if the passwords.lastResortHashThePasswords setting is true.

The last item is a callback that can be called to notify the application if the account creation succeeded. The id field should match the accounts id.

deleteAccount(strategy, account, who, done)

strategy

account

who

function(err){}

Delete an account using the strategy name provided. The strategy will select the middleware required. When no middleware matches the delete account event will be emitted. The account argument should be the name of the account. The who argument is used for accounting records. You can set this to the account name of who or what is creating the account.

The last item is a callback that can be called to notify you if the middleware succeeded. The id field should match the id of the account just deleted.

Accounting Messages

Accounting events are emitted to the accounting event. You can handle them any way you choose.