Skip to content

Commit 00a801c

Browse files
author
Curtis Lacy
committed
Split the service callback endpoints apart - there REALLY should be a way to combine these, but I can't work it out today.
1 parent d85e8fd commit 00a801c

File tree

1 file changed

+41
-11
lines changed

1 file changed

+41
-11
lines changed

server.js

+41-11
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ passport.use( 'facebook', new FacebookStrategy(
4747
owner: 'facebook:' + profile.id,
4848
accessToken: accessToken
4949
};
50+
console.trace( '** Facebook strategy!' );
5051
return done( null, allUserData );
5152
}
5253
));
@@ -156,7 +157,6 @@ app.configure(function () {
156157
if( req.query[ 'auth-return' ])
157158
{
158159
req.session[ 'auth-return' ] = req.query[ 'auth-return' ];
159-
console.log( '** DONE?: Store ' + req.query[ 'auth-return' ] + ' in the session.' );
160160
}
161161
next();
162162
});
@@ -183,17 +183,47 @@ app.get( '/auth/imap',
183183
}
184184
);
185185

186-
app.get( '/auth/:service/callback',
186+
app.get( '/auth/facebook/callback',
187+
passport.authenticate( 'facebook', { failureRedirect: '#auth-failure' } ),
187188
function( req, res ) {
188-
( passport.authenticate( req.params.service,
189-
{ failureRedirect: '#auth-failure' },
190-
function() {
191-
if( req.session[ 'auth-return' ] )
192-
res.redirect( req.session[ 'auth-return' ]);
193-
else
194-
res.redirect( '/' );
195-
}
196-
))( req, res );
189+
console.log( 'About to do redirect!' );
190+
if( req.session[ 'auth-return' ] )
191+
res.redirect( req.session[ 'auth-return' ]);
192+
else
193+
res.redirect( '/' );
194+
}
195+
);
196+
197+
app.get( '/auth/twitter/callback',
198+
passport.authenticate( 'twitter', { failureRedirect: '#auth-failure' } ),
199+
function( req, res ) {
200+
console.log( 'About to do redirect!' );
201+
if( req.session[ 'auth-return' ] )
202+
res.redirect( req.session[ 'auth-return' ]);
203+
else
204+
res.redirect( '/' );
205+
}
206+
);
207+
208+
app.get( '/auth/imap/callback',
209+
passport.authenticate( 'imap', { failureRedirect: '#auth-failure' } ),
210+
function( req, res ) {
211+
console.log( 'About to do redirect!' );
212+
if( req.session[ 'auth-return' ] )
213+
res.redirect( req.session[ 'auth-return' ]);
214+
else
215+
res.redirect( '/' );
216+
}
217+
);
218+
219+
app.get( '/auth/gmail/callback',
220+
passport.authenticate( 'gmail', { failureRedirect: '#auth-failure' } ),
221+
function( req, res ) {
222+
console.log( 'About to do redirect!' );
223+
if( req.session[ 'auth-return' ] )
224+
res.redirect( req.session[ 'auth-return' ]);
225+
else
226+
res.redirect( '/' );
197227
}
198228
);
199229

0 commit comments

Comments
 (0)