/collina-auth

Excercise for NodeJS Workshop

Primary LanguageJavaScript

collina-auth

Excercise for NodeJS Workshop

AuthService

LevelDB Logo

Fast & simple storage - a Node.js-style LevelDB wrapper

Build Status dependencies

NPM NPM

Introduction

AuthService is a simple ....

Basic usage

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
})