omnis.auth.mongodb
Omnis authorization plugin store data to mongodb
Usage
$ npm i omnis.auth.mongodb
Define module with exported method collection
- mongodb collection
;
Connect auth plugin to omnis
app;
Login as user
{ return req;}
Logout current user
{ return requser;}
Using auth model
;
Model methods
findOne(key)
: return user by primary key, findOne('test@test.com')findOneById(id)
: return user by _id(String or ObjectId)find(selector)
: return array of users by mongodb selectorcheckPassword(user, password)
: check password with user.passwordinsert(user)
: insert new user, user must contentpassword
fieldupdate(key, data)
: update user fields by primary keymakePassword(length, chars)
: generate new password with need length and writen chars