Excercise for NodeJS Workshop
Fast & simple storage - a Node.js-style LevelDB wrapper
AuthService is a simple ....
First you need to install AuthService!
$ npm install collina-auth
All operations are asynchronous although they don't necessarily require a callback if you don't need to know when the operation was performed.
const user = {
username: 'foo',
password: 'password',
details: {
a: 'b',
c: 'd',
},
}
let conf = {
dbname: 'bar'
}
var auth = require('collina-auth')(conf)
// 1) Add user, supply details.
// This will create user on the underlying store.
auth.addUser(user, function(err) {
if(err) /*handle!!!*/ return
//.. do stuff
})
// 2) Fetch User details
auth.fetchDetails('foo', function(err, details) {
if(err) /*handle!!!*/ return
//.. do stuff with details
})
})
// 3) Validate credentials
auth.authenticate('foo', 'password', function(err){
if(err) /*handle!!!*/ return
//.. do stuff
})