Skip to content

Commit

Permalink
clean up error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
mnutt committed Nov 27, 2014
1 parent 1b0a1fa commit 783bb7a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 21 deletions.
6 changes: 3 additions & 3 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ function loginPage(req, res, next) {
}

if(req.query.error) {
res.render('error.jade', { pageTitle: "An error occurred.", error: "The authentication method reports: " + req.query.error_description });
return;
req.flash('error', "The authentication method reports: " + req.query.error_description);
}

req.session.redirectTo = req.originalUrl;
Expand Down Expand Up @@ -124,7 +123,8 @@ app.on('error', function(err) {
});

everyauth.everymodule.moduleErrback(function(err, data) {
data.res.render('error.jade', { pageTitle: 'Sorry, there was an error.', error: "Perhaps something is misconfigured, or the provider is down." });
data.req.flash('error', "Perhaps something is misconfigured, or the provider is down.");
data.res.redirectTo('/');
});

// We don't actually use this
Expand Down
7 changes: 2 additions & 5 deletions lib/modules/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,8 @@ exports.setup = function(everyauth) {
})
.handleAuthCallbackError( function (req, res) {
var parsedUrl = url.parse(req.url, true);
res.render('auth_error.jade', {
pageTitle: 'Error authenticating with Github',
currentProvider: 'Github',
providers: everyauth.enabled,
error: parsedUrl.query.error });
req.flash('error', 'Error authenticating with Github: ' + parsedUrl.query.error);
res.redirectTo('/');
})
.redirectPath('/');

Expand Down
7 changes: 2 additions & 5 deletions lib/modules/google.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,8 @@ exports.setup = function(everyauth) {
})
.handleAuthCallbackError( function (req, res) {
var parsedUrl = url.parse(req.url, true);
res.render('auth_error.jade', {
pageTitle: 'Error authenticating with Google',
currentProvider: 'Google',
providers: everyauth.enabled,
error: parsedUrl.query.error });
req.flash('error', 'Error authenticating with Google: ' + parsedUrl.query.error);
res.redirectTo('/');
})
.convertErr( function (data) {
if(data.data) {
Expand Down
8 changes: 0 additions & 8 deletions views/error.jade

This file was deleted.

0 comments on commit 783bb7a

Please sign in to comment.