Skip to content

Commit

Permalink
merged in lemmy's contributions
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron McGuire committed May 17, 2015
1 parent 818f34a commit 71d760b
Show file tree
Hide file tree
Showing 20 changed files with 292 additions and 349 deletions.
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -89,6 +89,8 @@ Now that you have Mopidy up and running, let's setup up Apollo as our Frontend f

Once Apollo is started, navigate to your localhost: http://localhost:3000

Optionally on Debian/Ubuntu, you might want to start Apollo as a system [service](https://gist.github.com/peterhost/715255).

Finished!

### Notes
Expand Down
33 changes: 7 additions & 26 deletions controllers/auth.js
@@ -1,5 +1,4 @@
var usersController = require('./usersController');
var gravatar = require('gravatar');

module.exports = function () {
// =================================================
Expand All @@ -8,7 +7,7 @@ module.exports = function () {
var config,
UserController,
passport,
GoogleStrategy;
LocalStrategy;

// =================================================
// = public functions =
Expand All @@ -20,7 +19,7 @@ module.exports = function () {
self.app = p_app;
config = require('../config.js');
self.passport = passport = require('passport');
GoogleStrategy = require('passport-google').Strategy;
LocalStrategy = require('passport-local').Strategy;
_setup_passport();
console.log("AUTH INIT")

Expand All @@ -33,7 +32,6 @@ module.exports = function () {
ensureAuthenticatedHome : function(req, res, next){



if (req.isAuthenticated()) { res.redirect('/player') }
return next();

Expand All @@ -58,30 +56,13 @@ module.exports = function () {
passport.deserializeUser(function(user, done) {
done(null, user);
});

passport.use(new GoogleStrategy({
returnURL: 'http://localhost:3000/auth/google/return',
realm: 'http://localhost:3000/'
},
function(identifier, profile, done) {
// asynchronous verification, for effect...
process.nextTick(function () {

// To keep the example simple, the user's Google profile is returned to
// represent the logged-in user. In a typical application, you would want
// to associate the Google account with a user record in your database,
// and return that user instead.

var profile_photo_url = gravatar.url(profile.emails[0].value, {s: '200'});
profile.profile_photo = profile_photo_url;
profile.identifier = identifier;
passport.use(new LocalStrategy(
function(username, password, done) {


usersController.findOrCreate(profile,function(profile){
return done(null, profile);
});

usersController.findOrCreate(username,function(user){
done(null, user);
});

}
));
}
Expand Down

0 comments on commit 71d760b

Please sign in to comment.