Skip to content
This repository has been archived by the owner on Jun 14, 2023. It is now read-only.

Latest commit

 

History

History
49 lines (37 loc) · 879 Bytes

getting-started.md

File metadata and controls

49 lines (37 loc) · 879 Bytes

Getting started with township-accounts

Create the accounts object by calling the townshipAccounts constructor:

var townshipAccounts = require('township-accounts')
var level = require('level')
var db = level('db')

var accounts = townshipAccounts(db, {
  secret: 'not very secret'
})

Create an account with the register method:

var creds = {
  email: '[email protected]',
  password: 'weee'
}

accounts.register(creds, function (err, account) {
  console.log(err, account)
})

Log in with the login method:

var creds = {
  email: '[email protected]',
  password: 'weee'
}

accounts.login(creds, function (err, account) {
  console.log(err, account)
})

Log out with the logout method:

accounts.logout(accountKey, function (err, account) {
  console.log(err, account)
})

See more in the API documentation