Skip to content

Commit

Permalink
Merge pull request nrstott#97 from lpatters/master
Browse files Browse the repository at this point in the history
Added 'successRoute' to 'oauth' options.
  • Loading branch information
nrstott committed Apr 3, 2014
2 parents 3255a0d + 1a96159 commit 82c6432
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions lib/middleware/oauth.js
Expand Up @@ -15,7 +15,7 @@ module.exports = function oauthMiddleware(config, nextApp) {
loginRoute: '/auth/login',
logoutRoute: '/auth/logout',
callbackRoute: '/auth/callback',
errorRoute: '/'
errorUrl: '/'
};
options = _.extend(options, config);

Expand Down Expand Up @@ -94,9 +94,9 @@ module.exports = function oauthMiddleware(config, nextApp) {
var profile = q(options.parse(body, req)).then(function (profile) {
req.session('profile', profile);
req.session('access_token', accessToken);
return bogart.redirect(req.params.returnUrl || '/');
return bogart.redirect(options.successUrl || req.params.returnUrl || '/');
}).fail(function (error) {
var parsedUrl = url.parse(options.errorRoute, true);
var parsedUrl = url.parse(options.errorUrl, true);
parsedUrl.query.message = error.message;
var redirectUrl = url.format(parsedUrl);
return bogart.redirect(redirectUrl);
Expand Down
6 changes: 3 additions & 3 deletions lib/middleware/oauth2.js
Expand Up @@ -16,7 +16,7 @@ module.exports = function oauth2Middleware(config, nextApp) {
logoutRoute: '/auth/logout',
callbackRoute: '/auth/callback',
modalAuthRoute: '/auth/modalauth',
errorRoute: '/'
errorUrl: '/'
};
options = _.extend(options, config);

Expand Down Expand Up @@ -90,9 +90,9 @@ module.exports = function oauth2Middleware(config, nextApp) {
req.session('profile', profile);
req.session('access_token', accessToken);

return bogart.redirect(req.params.returnUrl || '/');
return bogart.redirect(options.successUrl || req.params.returnUrl || '/');
}).fail(function (error) {
var parsedUrl = url.parse(options.errorRoute, true);
var parsedUrl = url.parse(options.errorUrl, true);
parsedUrl.query.message = error.message;
var redirectUrl = url.format(parsedUrl);
return bogart.redirect(redirectUrl);
Expand Down

0 comments on commit 82c6432

Please sign in to comment.