Skip to content

Commit

Permalink
Graceful failure for invalid auth
Browse files Browse the repository at this point in the history
* Rather than just a 404 page... redirect to login page and denote with QSP when data present
* Some compliance with STYLEGUIDE.md max line length

Applies to OpenUserJS#1369 and OpenUserJS#37
  • Loading branch information
Martii committed May 22, 2018
1 parent ca90341 commit 4fad917
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion controllers/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ exports.auth = function (aReq, aRes, aNext) {
var authenticate = null;

// Just in case someone tries a bad /auth/* url
// or an auth has been EOL'd
if (!strategyInstances[strategy]) {
aNext();
aRes.redirect('/login?invalidauth');
return;
}

Expand Down
5 changes: 4 additions & 1 deletion controllers/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,10 @@ exports.userEditPreferencesPage = function (aReq, aRes, aNext) {
return aStrategy.display;
});

options.defaultStrategy = strategies[defaultStrategy] ? strategies[defaultStrategy].name : null;
options.defaultStrategy = strategies[defaultStrategy]
? strategies[defaultStrategy].name
: null;

options.defaultStrat = defaultStrategy;
options.haveOtherStrategies = options.usedStrategies.length > 0;

Expand Down

0 comments on commit 4fad917

Please sign in to comment.