-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
58 lines (40 loc) · 1.36 KB
/
app.js
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
47
48
49
50
51
52
53
54
55
56
57
58
const express = require('express');
const path = require('path');
const app = express();
const { auth } = require('express-openid-connect');
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');
const config = {
authRequired: false,
auth0Logout: true,
secret: 'dfgyuiopefgtyhuilalkdhjberhuirwiowenjsdhbdsagyquiwoieqwhwefhbdvs',
baseURL: 'http://localhost:4000',
clientID: '1E4ueHZEv1WyU4SGFEePihlVmM2agtfE',
issuerBaseURL: 'https://dev-z3nw6ewy.us.auth0.com'
};
// auth router attaches /login, /logout, and /callback routes to the baseURL
app.use(auth(config));
// ROUTES /******************************************************************* */
const { requiresAuth } = require('express-openid-connect');
app.get('/',requiresAuth(), function (req, res, next) {
res.render('index', {
isAuthenticated: req.oidc.isAuthenticated(),
userProfile: req.oidc.user
});
});
app.get('/Card',requiresAuth(), function (req, res, next) {
res.render('Card', {
isAuthenticated: req.oidc.isAuthenticated(),
userProfile: req.oidc.user
});
});
app.get('/Contacts',requiresAuth(), function (req, res, next) {
res.render('Contacts', {
isAuthenticated: req.oidc.isAuthenticated(),
userProfile: req.oidc.user
});
});
const port = 4000;
app.listen(port,()=>{
console.log("listening on port 4000 ");
})