Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zkochan/humble-auth
An hapi authentication strategy using humble-session.
https://github.com/zkochan/humble-auth
Last synced: 29 days ago
JSON representation
An hapi authentication strategy using humble-session.
- Host: GitHub
- URL: https://github.com/zkochan/humble-auth
- Owner: zkochan
- License: mit
- Created: 2015-10-19T20:39:32.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-11-25T19:50:08.000Z (about 8 years ago)
- Last Synced: 2024-04-25T22:02:54.468Z (9 months ago)
- Language: JavaScript
- Size: 12.7 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# humble-auth
A [hapi](http://hapijs.com/) authentication strategy using [humble-session](https://github.com/zkochan/humble-session).
[![Dependency Status](https://david-dm.org/zkochan/humble-auth/status.svg?style=flat)](https://david-dm.org/zkochan/humble-auth)
[![Build Status](https://travis-ci.org/zkochan/humble-auth.svg?branch=master)](https://travis-ci.org/zkochan/humble-auth)
[![npm version](https://badge.fury.io/js/humble-auth.svg)](http://badge.fury.io/js/humble-auth)## 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](https://github.com/zkochan/humble-session)
plugin for functioning.```js
var server = new Hapi.Server();
server.connection({ port: 8000 });server.register(require('humble-auth'), function(err) {
server.auth.strategy('session', 'session');
});
```## API
* [`login`](#login), `logIn`, `signIn`
* [`logout`](#logout), `logOut`, `signOut`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__
```js
/*...*/
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__
```js
request.logout(function() {
if (err) {
return reply(Boom.wrap(err));
}
reply.redirect('/');
});
```## License
MIT © [Zoltan Kochan](https://www.kochan.io)