Implement the Userific interface using a postgres database to store user data
JavaScript
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
share
test
.gitignore
.travis.yml
README.md
index.js
makefile
package.json

README.md

Userfic PostGRES backend

Build Status Dependency Status

Manage users using a postgres database. This module implements the abstract Userific interface

Installation

npm install -S userific-postgres

Requirements

This module requires that you have already have a table setup to handle your users. You can create a default users table using the text sql dump file located at ./share/users.sql. To create a users table with the required columns, execute the following command in the root of this module. This will create a users table in the specified database with all the required columns

psql -d <database_name> -f ./share/users.sql

Usage

var UserificPostGRES = require('userific-postgres')
var config = {
  host: 'localhost',              // the host of the postgres server
  port: '27017',                  // the port of the postgres server
  db: 'userific-postgres-test',   // the postgres database to use,
  table: 'users'                  // the table name of where users are stored in the database
  user: 'postgres username here', // optional
  pass: 'postgres password here', // optional
  useAccessTokens: true         // optional, when true users must supply a valid accessToken value when registering
}


var backend = new UserificPostGRES(config)

// you must call the asynchronous init function before this postgres backend can be used
backend.init(function(err) {
  // backend implements all the interface methods of the abstract Userific module
  var registerData = {
      email: 'foo@example.com',
      password: 'barPassword',
      accessToken: 'valid access token value here'
  }
  backend.register(registerData, function(err, user) {
    if (err) {
      inspect(err, 'error registering user via the userific mongoose backend')
      return
    }
    inspect(user, 'registered user correctly')
  })
})

Test

# install development dependencies
npm install
# run tests
npm test