An auth module for mainframe-core to handle multiple users.
npm install mainframe-module-auth``sh`
$ npm install mainframe-module-auth
To dock the module to the previously created mainframe, just type :
`js
var AuthModule = require('mainframe-module-auth')
// hook the auth module
// if filename is valid, the database is created into
// a file. else, it is in-memory only.
// name is optional
mainframe.dock(new AuthModule(filename, name="auth"))
`
You can then access the created auth module by typing :
`js`
var auth = mainframe.auth
auth is the default name of the module. If you specified a module name 'customname' while creating the module, you can access the module through 'mainframe.customname'
The following methods are available :
`js
var credentials = { name: '[username]', password: '[password]' }
// asychronously register an user
// onresult will be called with an error and a result object
// as parameters.
mainframe.auth.register(credentials, onresult)
// asychronously connects an user
// onresult will be called with an error and a result object
// as parameters.
mainframe.auth.login(credentials, onresult)
// instantly disconnects an user
mainframe.auth.logout(credentials)
``