Lockit MongoDB adapter
MongoDB adapter for Lockit.
Installation
npm install lockit-mongodb-adapter
var adapter = ;
Configuration
The following setting is required.
exportsdb = url: 'mongodb://127.0.0.1/' name: 'test' collection: 'users';
Features
1. Create user
adapter.save(name, email, pass, callback)
name
: String - i.e. 'john'email
: String - i.e. 'john@email.com'pass
: String - i.e. 'password123'callback
: Function -callback(err, user)
whereuser
is the new user now in our database.
The user
object has the following properties
name
: username chosen during sign upemail
: email that was provided at the beginningsignupTimestamp
: Date object to remember when the user signed upsignupToken
: unique token sent to user's email for email verificationsignupTokenExpires
: Date object usually 24h ahead ofsignupTimestamp
failedLoginAttempts
: save failed login attempts during login process, default is0
salt
: salt generated bycrypto.randomBytes()
derived_key
: password hash generated by pbkdf2_id
: document id
adapter;
2. Find user
adapter.find(match, query, callback)
match
: String - one of the following: 'name', 'email' or 'signupToken'query
: String - corresponds tomatch
, i.e. 'john@email.com'callback
: Function -callback(err, user)
adapter;
3. Update user
adapter.update(user, callback)
user
: Object - must have_id
and_rev
propertiescallback
: Function -callback(err, user)
-user
is the updated user object
// get a user from db firstadapter;
4. Remove user
adapter.remove(name, callback)
name
: Stringcallback
: Function -callback(err, res)
-res
istrue
if everything went fine
adapter;
Test
grunt
License
MIT