Skip to content

Commit b18cde1

Browse files
committed
Merge pull request #552 from Martii/authTweaks
Auth tweaks Auto-merge
2 parents 8a29a0c + 3ac0602 commit b18cde1

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

controllers/auth.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,12 @@ exports.auth = function (aReq, aRes, aNext) {
4545
var username = aReq.body.username || aReq.session.username;
4646

4747
function auth() {
48-
var authenticate = passport.authenticate(strategy);
48+
var authenticate = passport.authenticate(strategy, { failureRedirect: '/register?stratfail' });
4949

5050
// Just in case some dumbass tries a bad /auth/* url
51-
if (!strategyInstances[strategy]) { return aNext(); }
51+
if (!strategyInstances[strategy]) {
52+
return aNext();
53+
}
5254

5355
authenticate(aReq, aRes);
5456
}
@@ -61,13 +63,17 @@ exports.auth = function (aReq, aRes, aNext) {
6163
return aNext();
6264
}
6365

64-
if (!username) { return aRes.redirect('/register?noname'); }
66+
if (!username) {
67+
return aRes.redirect('/register?noname');
68+
}
6569
// Clean the username of leading and trailing whitespace,
6670
// and other stuff that is unsafe in a url
6771
username = cleanFilename(username.replace(/^\s+|\s+$/g, ''));
6872

6973
// The username could be empty after the replacements
70-
if (!username) { return aRes.redirect('/register?noname'); }
74+
if (!username) {
75+
return aRes.redirect('/register?noname');
76+
}
7177

7278
// Store the username in the session so we still have it when they
7379
// get back from authentication
@@ -113,10 +119,10 @@ exports.callback = function (aReq, aRes, aNext) {
113119
// The callback was called improperly
114120
if (!strategy || !username) { return aNext(); }
115121

116-
// Get the passport strategy instance so we can alter the _verfiy method
122+
// Get the passport strategy instance so we can alter the _verify method
117123
strategyInstance = strategyInstances[strategy];
118124

119-
// Hijak the private verify method so we can fuck shit up freely
125+
// Hijack the private verify method so we can fuck shit up freely
120126
// We use this library for things it was never intended to do
121127
if (openIdStrategies[strategy]) {
122128
strategyInstance._verify = function (aId, aDone) {
@@ -154,7 +160,7 @@ exports.callback = function (aReq, aRes, aNext) {
154160

155161
addSession(aReq, aUser, function () {
156162
if (newstrategy) {
157-
// Allow a user to link to another acount
163+
// Allow a user to link to another account
158164
return aRes.redirect('/auth/' + newstrategy);
159165
} else {
160166
// Delete the username that was temporarily stored

0 commit comments

Comments
 (0)