-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.mjs
More file actions
47 lines (29 loc) · 772 Bytes
/
server.mjs
File metadata and controls
47 lines (29 loc) · 772 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import 'dotenv/config';
import express from 'express';
import pkg from 'express-openid-connect';
const { auth, requiresAuth } = pkg;
const app = express();
app.set('view engine', 'pug');
const port = parseInt(process.env.PORT, 10);
app.use(
auth({
authorizationParams:{
response_type: 'code'
},
authRequired: false
}));
app.use((req, res, next) => {
res.locals.isAuthenticated = req.oidc.isAuthenticated();
res.locals.user = req.oidc.user;
console.log(res.locals);
next();
});
app.get('/', (req, res) => {
res.render('index');
});
app.get('/account', requiresAuth(), (req, res) => {
res.render('account');
});
app.listen(port, () =>{
console.log(`Listening on port ${port}...`)
});