1.0.0-alpha.4 • Published 7 years ago

brest-passport v1.0.0-alpha.4

Weekly downloads
56
License
-
Repository
github
Last release
7 years ago

#Brest-passport

Passport.js authentication wrapper for Brest library.

##Installation

In your project root run

$ npm install brest-passport --save

to install the latest version and save it to your package.json file.

##Setup

Upon Brest initialization, require brest-passport and add it to the plugins initialization inside brest.ready event callback. Use BrestPassport.passport to initialize authentication strategies.

In this example we use passport local strategy initialization from passport.js official guide.

const BrestPassport = require('brest-passport'),
	  LocalStrategy = require('passport-local').Strategy;

//...

brest.on('ready', function(){

	brest.use(
	  [   BrestPassport ]);
	
	const passport = BrestPassport.passport;
	
	passport.use(new LocalStrategy(
	  function(username, password, done) {
		User.findOne({ username: username }, function(err, user) {
		  if (err) { return done(err); }
		  if (!user) {
			return done(null, false, { message: 'Incorrect username.' });
		  }
		  if (!user.validPassword(password)) {
			return done(null, false, { message: 'Incorrect password.' });
		  }
		  return done(null, user);
		});
	  }
	));

});

Changes

1.0.0-alpha-4

  • Fixed issue with incorrect roles list on check

0.1.1

  • Can use user.role for a single role check
1.0.0-alpha.4

7 years ago

1.0.0-alpha.3

7 years ago

1.0.0-alpha.2

7 years ago

1.0.0-alpha.1

7 years ago

0.1.1

8 years ago

0.1.0

8 years ago

0.0.7

9 years ago

0.0.6

9 years ago

0.0.5-1

9 years ago

0.0.5

9 years ago

0.0.4-2

9 years ago

0.0.4

9 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1-d

10 years ago

0.0.1-c

10 years ago

0.0.1-b

10 years ago

0.0.1

10 years ago