humble-auth
v0.2.1
Published
A hapi authentication strategy using humble-session.
Downloads
9
Maintainers
Readme
humble-auth
A hapi authentication strategy using humble-session.
Installation
npm i --save humble-auth
Usage
The plugin has to be registered and the authentication scheme created.
Humble-auth also needs the humble-session plugin for functioning.
var server = new Hapi.Server();
server.connection({ port: 8000 });
server.register(require('humble-auth'), function(err) {
server.auth.strategy('session', 'session');
});
API
Saves the passed user to the session, making him logged in.
Arguments
user
- The object the identifies the user.
cb(err)
- A callback which is called once the user was saved to the session.
Examples
/*...*/
request.login({
id: user.id
}, function(err) {
if (err) {
return reply(Boom.wrap(err));
}
reply.redirect('/some-private-page');
});
Removes the current user from the session, terminating his login session.
Arguments
cb(err)
- Optional A callback which is called once the user is removed from
the session.
Examples
request.logout(function() {
if (err) {
return reply(Boom.wrap(err));
}
reply.redirect('/');
});
License
MIT