@@ -42,7 +42,13 @@ passport.serializeUser(function (aUser, aDone) {
42
42
// Setup all the auth strategies
43
43
var openIdStrategies = { } ;
44
44
Strategy . find ( { } , function ( aErr , aStrategies ) {
45
- // WARNING: No err handling
45
+ if ( aErr ) {
46
+ // Some possible catastrophic error
47
+ console . error ( colors . red ( aErr ) ) ;
48
+
49
+ process . exit ( 1 ) ;
50
+ return ;
51
+ }
46
52
47
53
// Get OpenId strategies
48
54
for ( var name in allStrategies ) {
@@ -161,7 +167,16 @@ exports.auth = function (aReq, aRes, aNext) {
161
167
if ( aReq . session . cookie . sameSite !== 'lax' ) {
162
168
aReq . session . cookie . sameSite = 'lax' ;
163
169
aReq . session . save ( function ( aErr ) {
164
- // WARNING: No err handling
170
+ if ( aErr ) {
171
+ // Some possible catastrophic error
172
+ console . error ( colors . red ( aErr ) ) ;
173
+
174
+ statusCodePage ( aReq , aRes , aNext , {
175
+ statusCode : 500 ,
176
+ statusMessage : 'Save Session failed.'
177
+ } ) ;
178
+ return ;
179
+ }
165
180
166
181
authenticate ( aReq , aRes , aNext ) ;
167
182
} ) ;
@@ -171,6 +186,7 @@ exports.auth = function (aReq, aRes, aNext) {
171
186
}
172
187
173
188
function sessionauth ( ) {
189
+ var captchaToken = aReq . body [ 'g-captcha-response' ] ?? aReq . body [ 'h-captcha-response' ] ;
174
190
// Yet another passport hack.
175
191
// Initialize the passport session data only when we need it. i.e. late binding
176
192
if ( ! aReq . session [ passportKey ] && aReq . _passport . session ) {
@@ -180,6 +196,16 @@ exports.auth = function (aReq, aRes, aNext) {
180
196
181
197
// Save redirect url from the form submission on the session
182
198
aReq . session . redirectTo = aReq . body . redirectTo || getRedirect ( aReq ) ;
199
+
200
+ // Save the token from the captcha on the session and remove from body
201
+ if ( captchaToken ) {
202
+ aReq . session . captchaToken = captchaToken ;
203
+ aReq . session . captchaSuccess = aReq . hcaptcha ;
204
+
205
+ delete aReq . body [ 'g-captcha-response' ] ;
206
+ delete aReq . body [ 'h-captcha-response' ] ;
207
+ delete aReq . hcaptcha ;
208
+ }
183
209
}
184
210
185
211
function anteauth ( ) {
@@ -411,7 +437,16 @@ exports.callback = function (aReq, aRes, aNext) {
411
437
412
438
if ( ! aReq . session . passport . oujsOptions . authAttach ) {
413
439
expandSession ( aReq , aUser , function ( aErr ) {
414
- // WARNING: No err handling
440
+ if ( aErr ) {
441
+ // Some possible catastrophic error
442
+ console . error ( colors . red ( aErr ) ) ;
443
+
444
+ statusCodePage ( aReq , aRes , aNext , {
445
+ statusCode : 500 ,
446
+ statusMessage : 'Expand Session failed.'
447
+ } ) ;
448
+ return ;
449
+ }
415
450
416
451
aRes . redirect ( doneUri ) ;
417
452
} ) ;
0 commit comments