Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 39 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ So far, `everyauth` enables you to login via:
<td> <a href="http://github.com/wnadeau">Winfred Nadeau</a>
<tr> <td> <img src="https://github.com/bnoguchi/everyauth/raw/master/media/mendeley.ico" style="vertical-align:middle"> Mendeley
<td> <a href="https://github.com/edy-b">Eduard Baun</a>
<tr> <td> <img src="https://github.com/bnoguchi/everyauth/raw/master/media/smarterer.ico" style="vertical-align:middle"> Smarterer
<td> <a href="https://github.com/kaizenpack">kaizenpack</a>
</tbody>
<tbody id=misc>
<tr> <td> <img src="https://github.com/bnoguchi/everyauth/raw/master/media/box.ico" style="vertical-align:middle"> Box.net <td>
Expand Down Expand Up @@ -794,7 +796,7 @@ everyauth.password
var promise = this.Promise()
, password = newUserAttrs.password;

delete newUserAttrs[password]; // Don't store password
delete newUserAttrs.password; // Don't store password
newUserAttrs.salt = bcrypt.genSaltSync(10);
newUserAttrs.hash = bcrypt.hashSync(password, salt);

Expand Down Expand Up @@ -1065,10 +1067,10 @@ var everyauth = require('everyauth')
everyauth.google
.appId('YOUR CLIENT ID HERE')
.appSecret('YOUR CLIENT SECRET HERE')
.scope('https://www.google.com/m8/feeds') // What you want access to
.scope('https://www.googleapis.com/auth/userinfo.profile') // What you want access to
.handleAuthCallbackError( function (req, res) {
// If a user denies your app, Google will redirect the user to
// /auth/facebook/callback?error=access_denied
// /auth/google/callback?error=access_denied
// This configurable route handler defines how you want to respond to
// that.
// If you do not configure this, everyauth renders a default fallback
Expand Down Expand Up @@ -2195,6 +2197,40 @@ connect(
).listen(3000);
```

### Smarterer

You will need to register for an app id [here](http://www.smarterer.com/). Implementation details follow the same pattern as with other
oauth2 implementations.

```javascript

var everyauth = require('everyauth')
, connect = require('connect');

everyauth.smarterer
.appId('YOUR APP ID')
.appSecret('YOUR APP SECRET')
.findOrCreateUser(function(session, accessToken, accessTokenSecret, userData) {
// find or create user logic goes here
// userData.userName will contain the smarterer username for the authenticated user
// userData.badges will contain the scores on quizes
})
.redirectPath('/');

var routes = function (app) {
// Define your routes here
};

connect(
connect.bodyParser()
, connect.cookieParser()
, connect.session({secret: 'whodunnit'})
, everyauth.middleware()
, connect.router(routes);
).listen(3000);
```


### Box.net

```javascript
Expand Down
6 changes: 3 additions & 3 deletions lib/modules/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ oauthModule.submodule('github')
})

.oauthHost('https://github.com')
.apiHost('https://github.com/api/v2/json')
.apiHost('https://api.github.com')

.authPath('/login/oauth/authorize')
.accessTokenPath('/login/oauth/access_token')
Expand All @@ -21,9 +21,9 @@ oauthModule.submodule('github')

.fetchOAuthUser( function (accessToken) {
var p = this.Promise();
this.oauth.get(this.apiHost() + '/user/show', accessToken, function (err, data) {
this.oauth.get(this.apiHost() + '/user', accessToken, function (err, data) {
if (err) return p.fail(err);
var oauthUser = JSON.parse(data).user;
var oauthUser = JSON.parse(data);
p.fulfill(oauthUser);
})
return p;
Expand Down
11 changes: 9 additions & 2 deletions lib/modules/openid.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,18 @@ everyModule.submodule('openid')
if (!this._myHostname || this._alwaysDetectHostname) {
this.myHostname(extractHostname(req));
}


var self = this;
var p = this.Promise();

this.relyingParty.authenticate(req.query[this.openidURLField()], false, function(err,authenticationUrl){
if(err) return p.fail(err);
this.redirect(res, authenticationUrl);

self.redirect(res, authenticationUrl);
});

p.fulfill();
return p;
})
.getSession( function(req) {
return req.session;
Expand Down
30 changes: 30 additions & 0 deletions lib/modules/smarterer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
var oauthModule = require('./oauth2')
, querystring= require('querystring');

var smarterer = module.exports =
oauthModule.submodule('smarterer')
.oauthHost('https://smarterer.com')
.apiHost('https://smarterer.com')

.entryPath('/auth/smarterer')
.callbackPath('/auth/smarterer/callback')

.authQueryParam('callback_url', function() {
return this._myHostname + this._callbackPath;
})

.accessTokenParam('grant_type', 'authorization_code')


.fetchOAuthUser( function (accessToken) {
var p = this.Promise();
this.oauth.get(this.apiHost() + '/api/badges', accessToken, function (err, data) {
if (err) return p.fail(err.error_message);
var oauthUser = JSON.parse(data);
p.fulfill(oauthUser);
})
return p;
})
.convertErr( function (data) {
return new Error(data.error_message);
});
Binary file added media/smarterer.ico
Binary file not shown.