Skip to content

Commit

Permalink
using www.eyeem > otherwise we produce a 301 redirect
Browse files Browse the repository at this point in the history
trying to conform to passportjs profile covention
conforming to express3 in example
added all node_modules to .gitignore
little more user info on index when logged in
note that EJS layouts aren't working that way with express3. Too lazy to fix now.
  • Loading branch information
elmariachi111 committed Mar 21, 2013
1 parent 62b8036 commit c13f467
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 24 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -5,5 +5,6 @@
.idea

# Node.js
node_modules/*
node_modules
npm-debug.log
*.tgz
2 changes: 1 addition & 1 deletion examples/login/app.js
Expand Up @@ -48,7 +48,7 @@ passport.use(new EyeemStrategy({



var app = express.createServer();
var app = module.exports = express();

// configure Express
app.configure(function() {
Expand Down
4 changes: 3 additions & 1 deletion examples/login/views/index.ejs
@@ -1,5 +1,7 @@
<% if (!user) { %>
<h2>Welcome! Please log in.</h2>
<a href="/auth/eyeem">Login with Eyeem</a>
<% } else { %>
<h2>Hello, <%= user.username %>.</h2>
<h2><img src="<%= user._json.user.thumbUrl %>" style="float:left;"/> Hello, <%= user.username %>.</h2>
Visit <a href="<%= user._json.user.webUrl %>" target="_blank">your Eyeem profile</a>
<% } %>
42 changes: 21 additions & 21 deletions lib/passport-eyeem/strategy.js
Expand Up @@ -71,27 +71,27 @@ util.inherits(Strategy, OAuth2Strategy);
*/
Strategy.prototype.userProfile = function(accessToken, done) {

this._oauth2.get('https://eyeem.com/api/v2/users/me', accessToken, function (err, body, res) {
if (err) { return done(new InternalOAuthError('failed to fetch user profile', err)); }
try {
var json = JSON.parse(body);
var profile = { provider: 'eyeem' };
profile.id = json.user.id;
profile.displayName = json.user.fullname;
profile.name = json.user.fullname;
//{ familyName: json.data.last_name, givenName: json.data.first_name };
profile.username = json.user.nickname;
profile._raw = body;
profile._json = json;
done(null, profile);
} catch(e) {
done(e);
}
});
this._oauth2.get('http://www.eyeem.com/api/v2/users/me', accessToken, function (err, body, res) {
if (err) { return done(new InternalOAuthError('failed to fetch user profile', err)); }

try {
var json = JSON.parse(body);

var profile = { provider: 'eyeem' };
profile.id = json.user.id;
profile.displayName = json.user.fullname;
profile.name = json.user.fullname;
{ familyName: json.name }; // have no better idea, only the "real name" is provided
profile.username = json.user.nickname;

profile._raw = body;
profile._json = json;

done(null, profile);
} catch(e) {
done(e);
}
});
}


Expand Down

0 comments on commit c13f467

Please sign in to comment.