Skip to content

Commit

Permalink
Merge pull request hapijs#88 from hapijs/client
Browse files Browse the repository at this point in the history
Expose OAuth interface. Closes hapijs#48
  • Loading branch information
Eran Hammer committed May 16, 2015
2 parents d3ac0be + e498484 commit d9adbc7
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
13 changes: 9 additions & 4 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,26 @@ var Providers = require('./providers');
var internals = {};


// Utilities

exports.providers = Providers;
exports.oauth = OAuth;


// Plugin

exports.register = function (server, options, next) {

server.auth.scheme('bell', internals.implementation);
server.expose('oauth', OAuth);
next();
};


exports.register.attributes = {
pkg: require('../package.json')
};


exports.providers = Providers;


internals.schema = Joi.object({
provider: Joi.object({
name: Joi.string().optional().default('custom'),
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "bell",
"description": "Third-party login plugin for hapi",
"version": "2.7.1",
"version": "2.8.0",
"repository": "git://github.com/hapijs/bell",
"main": "index",
"keywords": [
Expand Down
17 changes: 17 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,4 +275,21 @@ describe('Bell', function () {
});
});
});

it('exposes OAuth implementation', function (done) {

expect(Bell.oauth.Client).to.be.function();
done();
});

it('exposes OAuth via plugin', function (done) {

var server = new Hapi.Server();
server.connection({ host: 'localhost', port: 80 });
server.register(Bell, function (err) {

expect(server.plugins.bell.oauth.Client).to.be.function();
done();
});
});
});

0 comments on commit d9adbc7

Please sign in to comment.