@@ -39,6 +39,11 @@ var server = app.listen(9215, function () {
3939app . set ( 'view engine' , 'html' ) ;
4040app . set ( 'views' , require ( 'path' ) . join ( __dirname , '/view' ) ) ;
4141app . engine ( 'html' , hogan ) ;
42+ const partials = {
43+ smallNavbar : 'components/smallNavbar' ,
44+ fullNavbar : 'components/fullNavbar' ,
45+ footer : 'components/footer' ,
46+ }
4247
4348// Create a session-store to be used by both the express-session
4449// middleware and the keycloak middleware.
@@ -271,7 +276,7 @@ app.get('/error', (req, res) => {
271276 res . status ( 500 ) . send ( "An error occurred." )
272277} ) ;
273278app . 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 />" ) } ) ;
275280} ) ;
276281// 'GET returnURL'
277282// `passport.authenticate` will try to authenticate the content returned in
@@ -309,30 +314,9 @@ app.post('/auth/openid/return',
309314
310315// 'logout' route, logout from passport, and destroy the session with AAD.
311316app . get ( '/logout' , function ( req , res ) {
312- req . session . destroy ( function ( err ) {
313- req . logOut ( ) ;
314- res . redirect ( config . destroySessionUrl ) ;
315- } ) ;
317+ req . session = null ;
316318} ) ;
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- }
333319
334- return result ;
335- }
336320function validateArray ( userGroups , accessGroups ) {
337321 for ( const item of userGroups ) {
338322 if ( accessGroups . includes ( item ) ) {
@@ -357,12 +341,12 @@ app.use(async (req, res, next) => {
357341
358342app . get ( '/' , async function ( req , res ) {
359343 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 } ) ;
361345 return
362346} )
363347
364348app . 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 } } ) : { } } )
366350 return
367351} )
368352
@@ -425,6 +409,12 @@ app.get('/mylinks', ensureAuthenticated, async function (req, res) {
425409 } )
426410 delegatedLinks = delegatedLinks . filter ( word => word . email != email ) ;
427411 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 ,
428418 data,
429419 name,
430420 email,
@@ -504,11 +494,11 @@ app.get('/:id', async function (req, res) {
504494 res . redirect ( atob ( url [ 0 ] . url ) )
505495 return
506496 } 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 , } )
508498 return
509499 }
510500 } 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 , } )
512502 return
513503 }
514504
0 commit comments