Simple file storage for credentials (Node.js module).
- Stores credentials (user, hashed password) and role name into JSON file
- Handles verification of given username and password
- Reads role for given user
- Passwords are hashed with bcrypt
npm install jasstor
var Jasstor = require('jasstor');
var jasstor = new Jasstor('credentials.txt');
//Encrypt and store password into JSON file
jasstor.saveCredentials('user', 'password', 'role', function(err){
if (err) {
//handle error
}
});
//Verify credentials and read user's role
jasstor.verify('user', 'password', function(err, role){
if (role){
//user authenticated with role
} else {
//user don't exist or wrong password
}
});
//Read role for user
jasstor.getRole('user', function (err, role) {
if (role){
//user has role
} else {
//user don't exist
}
});
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Gulp.
npm install
npm test
Copyright (c) 2014 Lubos Krnac. Licensed under the MIT license.