@@ -39,6 +39,11 @@ var server = app.listen(9215, function () {
39
39
app . set ( 'view engine' , 'html' ) ;
40
40
app . set ( 'views' , require ( 'path' ) . join ( __dirname , '/view' ) ) ;
41
41
app . engine ( 'html' , hogan ) ;
42
+ const partials = {
43
+ smallNavbar : 'components/smallNavbar' ,
44
+ fullNavbar : 'components/fullNavbar' ,
45
+ footer : 'components/footer' ,
46
+ }
42
47
43
48
// Create a session-store to be used by both the express-session
44
49
// middleware and the keycloak middleware.
@@ -271,7 +276,7 @@ app.get('/error', (req, res) => {
271
276
res . status ( 500 ) . send ( "An error occurred." )
272
277
} ) ;
273
278
app . get ( '/unauthorized' , ( req , res ) => {
274
- return res . status ( 401 ) . render ( 'unauthorized.html' , { productName : config . branding . title , logoPath : config . branding . logoPath , copyrightOwner : config . branding . copyrightOwner , statusURL : config . branding . statusURL , orgHome : config . branding . orgHome , groups : config . groups_permitted . toString ( ) . replaceAll ( "," , "<br />" ) } ) ;
279
+ return res . status ( 401 ) . render ( 'unauthorized.html' , { partials , productName : config . branding . title , logoPath : config . branding . logoPath , copyrightOwner : config . branding . copyrightOwner , statusURL : config . branding . statusURL , orgHome : config . branding . orgHome , groups : config . groups_permitted . toString ( ) . replaceAll ( "," , "<br />" ) } ) ;
275
280
} ) ;
276
281
// 'GET returnURL'
277
282
// `passport.authenticate` will try to authenticate the content returned in
@@ -309,30 +314,9 @@ app.post('/auth/openid/return',
309
314
310
315
// 'logout' route, logout from passport, and destroy the session with AAD.
311
316
app . get ( '/logout' , function ( req , res ) {
312
- req . session . destroy ( function ( err ) {
313
- req . logOut ( ) ;
314
- res . redirect ( config . destroySessionUrl ) ;
315
- } ) ;
317
+ req . session = null ;
316
318
} ) ;
317
- function intersect_safe ( a , b )
318
- {
319
- var ai = 0 , bi = 0 ;
320
- var result = [ ] ;
321
-
322
- while ( ai < a . length && bi < b . length )
323
- {
324
- if ( a [ ai ] < b [ bi ] ) { ai ++ ; }
325
- else if ( a [ ai ] > b [ bi ] ) { bi ++ ; }
326
- else /* they're equal */
327
- {
328
- result . push ( a [ ai ] ) ;
329
- ai ++ ;
330
- bi ++ ;
331
- }
332
- }
333
319
334
- return result ;
335
- }
336
320
function validateArray ( userGroups , accessGroups ) {
337
321
for ( const item of userGroups ) {
338
322
if ( accessGroups . includes ( item ) ) {
@@ -357,12 +341,12 @@ app.use(async (req, res, next) => {
357
341
358
342
app . get ( '/' , async function ( req , res ) {
359
343
if ( req . isAuthenticated ( ) ) { return res . redirect ( '/create' ) }
360
- res . render ( 'home.html' , { productName : config . branding . title , logoPath : config . branding . logoPath , copyrightOwner : config . branding . copyrightOwner , statusURL : config . branding . statusURL , orgHome : config . branding . orgHome , loginProvider : config . branding . loginProvider } ) ;
344
+ res . render ( 'home.html' , { partials , productName : config . branding . title , logoPath : config . branding . logoPath , copyrightOwner : config . branding . copyrightOwner , statusURL : config . branding . statusURL , orgHome : config . branding . orgHome , loginProvider : config . branding . loginProvider } ) ;
361
345
return
362
346
} )
363
347
364
348
app . get ( '/create' , ensureAuthenticated , async function ( req , res ) {
365
- res . render ( 'index.html' , { productName : config . branding . title , logoPath : config . branding . logoPath , copyrightOwner : config . branding . copyrightOwner , statusURL : config . branding . statusURL , orgHome : config . branding . orgHome , email : req . user . _json . preferred_username , name : req . user . displayName , baseURL, userGroups : req . user . _json . groups !== undefined ? req . user . _json . groups . map ( ( item ) => { return { group : item } } ) : { } } )
349
+ res . render ( 'index.html' , { partials , productName : config . branding . title , logoPath : config . branding . logoPath , copyrightOwner : config . branding . copyrightOwner , statusURL : config . branding . statusURL , orgHome : config . branding . orgHome , email : req . user . _json . preferred_username , name : req . user . displayName , baseURL, userGroups : req . user . _json . groups !== undefined ? req . user . _json . groups . map ( ( item ) => { return { group : item } } ) : { } } )
366
350
return
367
351
} )
368
352
@@ -425,6 +409,12 @@ app.get('/mylinks', ensureAuthenticated, async function (req, res) {
425
409
} )
426
410
delegatedLinks = delegatedLinks . filter ( word => word . email != email ) ;
427
411
res . render ( 'mylinks' , {
412
+ partials,
413
+ productName : config . branding . title ,
414
+ logoPath : config . branding . logoPath ,
415
+ copyrightOwner : config . branding . copyrightOwner ,
416
+ statusURL : config . branding . statusURL ,
417
+ orgHome : config . branding . orgHome ,
428
418
data,
429
419
name,
430
420
email,
@@ -504,11 +494,11 @@ app.get('/:id', async function (req, res) {
504
494
res . redirect ( atob ( url [ 0 ] . url ) )
505
495
return
506
496
} else {
507
- res . status ( 404 ) . render ( '404' , { productName : config . branding . title , logoPath : config . branding . logoPath , copyrightOwner : config . branding . copyrightOwner , statusURL : config . branding . statusURL , } )
497
+ res . status ( 404 ) . render ( '404' , { partials , productName : config . branding . title , logoPath : config . branding . logoPath , copyrightOwner : config . branding . copyrightOwner , statusURL : config . branding . statusURL , } )
508
498
return
509
499
}
510
500
} catch {
511
- res . status ( 500 ) . render ( '500' , { productName : config . branding . title , logoPath : config . branding . logoPath , copyrightOwner : config . branding . copyrightOwner , statusURL : config . branding . statusURL , } )
501
+ res . status ( 500 ) . render ( '500' , { partials , productName : config . branding . title , logoPath : config . branding . logoPath , copyrightOwner : config . branding . copyrightOwner , statusURL : config . branding . statusURL , } )
512
502
return
513
503
}
514
504
0 commit comments