Skip to content

Commit

Permalink
Merge branch 'master' of github.com:1602/compound-passport
Browse files Browse the repository at this point in the history
  • Loading branch information
1602 committed Oct 7, 2013
2 parents 091ee2e + ea73d63 commit 2935356
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
5 changes: 3 additions & 2 deletions README.md
Expand Up @@ -3,10 +3,11 @@
PassportJS auth library integrated into CompoundJS. Why this package needed? To be honest, PassportJS is dead-simple in integrating. But it can be simplier. This package for authentication without extra coding, just configure it and use

## Setup project

Put the following configuration in ```config/passport.yml```.
```yaml
development:
baseURL: 'http://localhost:3000/'
local: true
google: true
github:
clientID: "a8578b8dc47834908338"
Expand All @@ -21,7 +22,7 @@ production:
secret: "...."
```

Add module to config/autoload.js:
Add module to ```config/autoload.js```:

```javascript
module.exports = function() {
Expand Down
6 changes: 4 additions & 2 deletions lib/passport.js
@@ -1,5 +1,6 @@
var Passport = require('passport').Passport;
require('yaml-js');
var yaml = require('yaml-js');
var fs = require('fs');

exports.strategies = [];

Expand Down Expand Up @@ -46,7 +47,8 @@ exports.init = function (compound) {
}
})();

var conf = require(app.root + '/config/passport.yml');
var conf = fs.readFileSync(app.root + '/config/passport.yml', 'utf8').toString();
var conf = yaml.load(conf);
if (conf && conf instanceof Array) conf = conf[0];
conf = conf[app.set('env')];
Object.keys(exports.strategies).forEach(function (str) {
Expand Down
2 changes: 1 addition & 1 deletion lib/strategies/local.js
Expand Up @@ -36,7 +36,7 @@ exports.init = function (conf, app) {

app.post('/login', passport.authenticate('local', {
failureRedirect: '/login',
failureFlash: true
failureFlash: conf.failureFlash
}), exports.redirectOnSuccess);

};
Expand Down

0 comments on commit 2935356

Please sign in to comment.