0.2.1 • Published 8 years ago

humble-auth v0.2.1

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

humble-auth

A hapi authentication strategy using humble-session.

Dependency Status Build Status npm version

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

0.2.1

8 years ago

0.2.0

9 years ago

0.1.0

9 years ago

0.0.0

9 years ago