mnkycode-user
v1.1.1
Published
MNKYCODE User Module
Downloads
4
Readme
MNKYCODE - User Module
Install
npm install -S mnkycode-user
Requirements
You need a running mongoose instance like:
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/testing', {}, function (err) {
if(err) throw err;
});
Usage
Create User
var User = require('mnkycode-user')
var data = {
displayname: TestUser,
password: 12351235,
email: [email protected]
}
var user = new User(data)
user.create(function(code, data){
// on success
// code = 201
// data = json object
// on exist
// code = 200
// data = null
})
Read User
var User = require('mnkycode-user')
var data = {
token: UserToken
}
var user = new User(data)
user.read(function(code, data){
// on success
// code = 200
// data = json object
// on error
// code = 400
// data = null
})
Update User
var User = require('mnkycode-user')
var data = {
token: UserToken,
email: '[email protected]',
password: 'newMasterPassword'
}
var user = new User(data)
user.update(function(code, data){
// on success
// code = 200
// data = json object
// on error
// code = 400
// data = null
})
Delete User
var User = require('mnkycode-user')
var data = {
token: UserToken
}
var user = new User(data)
user.update(function(code, data){
// on success
// code = 200
// data = json object
// on exist
// code = 400
// data = null
})
Login User
var User = require('mnkycode-user')
var data = {
displayname: UserDisplayname,
password: UserPassword
};
var user = new User(data);
user.login(function(code, data){
// on success
// code = 200
// data = json object
// on exist
// code = 400
// data = null
})
Logout User
var User = require('mnkycode-user')
var data = {
displayname: UserDisplayname,
password: UserPassword
};
var user = new User(data);
user.logout(function(code, data){
// on success
// code = 200
// data = true
// on exist
// code = 400
// data = null
})
Schema
| Name | Type | Description | | ------------- |:-------------:| -----:| | displayname | String | - | | username | String | displayname.toLowerCase() | | email | String | - | | password | String | pbkdf2 | | token | String | JWT | | signup | Date | Date.now() |
Test
npm test