Source code of a tutorial regarding User authentication with Hapi, Hapi-auth-cookie and Mongoose
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Accompanying blog posts

First version: Source code of a post regarding User authentication with Hapi, Passport and Mongoose located at:

Second version (Hapi 6):

Third version (Hapi 8):

Version 2.0.0

Lots of changes in this version, since some major dependencies have had several updates.

Most notably: passport-local-mongoose. Earlier versions used passport-local-mongoose 0.3.0. It has since been updated to 3.1.0 and due to security implications it switched from sha1 to sha256. If you decide to upgrade a production system remember that your users will not be able to log in since the digest algorithm was changed!

The update also provided certain new error messages which have been added to AuthProject 2.0.0.

Additionally, I have added Vision, Hapi's view engine plugin, to get rid of the HTML in the route handlers.

Getting it to run

Before you're able to get it working you have to enter your MongoLab credentials or alter to code to use a local MongoDB database. Copy the config.example.js file to config.js and enter the following information:

  • Username of your dbuser
  • Password of that dbuser (dbpassword)
  • Replace the first part of the hostname in the url
  • Replace the port number in the url

These are all supplied by MongoLab.

After changing these settings don't forget to run

npm install

to install the dependencies.


Feel free to do whatever you like with the code.