@@ -8,7 +8,6 @@ var isDbg = require('../libs/debug').isDbg;
8
8
//
9
9
10
10
//--- Dependency inclusions
11
- var request = require ( 'request' ) ;
12
11
var passport = require ( 'passport' ) ;
13
12
var url = require ( 'url' ) ;
14
13
var colors = require ( 'ansi-colors' ) ;
@@ -162,6 +161,18 @@ exports.auth = function (aReq, aRes, aNext) {
162
161
}
163
162
}
164
163
164
+ function sessionauth ( ) {
165
+ // Yet another passport hack.
166
+ // Initialize the passport session data only when we need it. i.e. late binding
167
+ if ( ! aReq . session [ passportKey ] && aReq . _passport . session ) {
168
+ aReq . session [ passportKey ] = { } ;
169
+ aReq . _passport . session = aReq . session [ passportKey ] ;
170
+ }
171
+
172
+ // Save redirect url from the form submission on the session
173
+ aReq . session . redirectTo = aReq . body . redirectTo || getRedirect ( aReq ) ;
174
+ }
175
+
165
176
function anteauth ( ) {
166
177
// Store the useragent always so we still have it when they
167
178
// get back from authentication and/or attaching
@@ -222,41 +233,19 @@ exports.auth = function (aReq, aRes, aNext) {
222
233
return ;
223
234
}
224
235
236
+ sessionauth ( ) ;
225
237
226
- // TODO: Send out token and sitekey back to https://hcaptcha.com/siteverify
227
- // ... routine with req hcaptcha?
228
- // If successful then do below and call anteauth otherwise redirect
229
-
230
- // Yet another passport hack.
231
- // Initialize the passport session data only when we need it. i.e. late binding
232
- if ( ! aReq . session [ passportKey ] && aReq . _passport . session ) {
233
- aReq . session [ passportKey ] = { } ;
234
- aReq . _passport . session = aReq . session [ passportKey ] ;
235
- }
236
-
237
- // Save redirect url from the form submission on the session
238
- aReq . session . redirectTo = aReq . body . redirectTo || getRedirect ( aReq ) ;
239
-
240
- // Store the username always so we still have it when they
241
- // get back from authentication
242
- aReq . session . username = username ;
243
-
244
- anteauth ( ) ;
238
+ // Store the username always so we still have it when they
239
+ // get back from authentication
240
+ aReq . session . username = username ;
245
241
242
+ anteauth ( ) ;
246
243
247
244
} else {
248
245
// Already validated username
249
246
username = aReq . session . username || ( authedUser ? authedUser . name : null ) ;
250
247
251
- // Yet another passport hack.
252
- // Initialize the passport session data only when we need it. i.e. late binding
253
- if ( ! aReq . session [ passportKey ] && aReq . _passport . session ) {
254
- aReq . session [ passportKey ] = { } ;
255
- aReq . _passport . session = aReq . session [ passportKey ] ;
256
- }
257
-
258
- // Save redirect url from the form submission on the session
259
- aReq . session . redirectTo = aReq . body . redirectTo || getRedirect ( aReq ) ;
248
+ sessionauth ( ) ;
260
249
261
250
// Allow a logged in user to add a new strategy
262
251
if ( strategy ) {
0 commit comments