Skip to content

Commit b843f21

Browse files
author
derisen
committed
update packages, update readme
1 parent 698b67c commit b843f21

55 files changed

Lines changed: 4985 additions & 11953 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1-Authentication/1-sign-in/App/app.js

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,11 @@ const SERVER_PORT = process.env.PORT || 4000;
1717
// initialize express
1818
const app = express();
1919

20-
app.set('views', path.join(__dirname, './views'));
21-
app.set('view engine', 'ejs');
22-
23-
app.use('/css', express.static(path.join(__dirname, 'node_modules/bootstrap/dist/css')));
24-
app.use('/js', express.static(path.join(__dirname, 'node_modules/bootstrap/dist/js')));
25-
26-
app.use(express.static(path.join(__dirname, './public')));
27-
2820
/**
2921
* Using express-session middleware. Be sure to familiarize yourself with available options
3022
* and set them as desired. Visit: https://www.npmjs.com/package/express-session
3123
*/
32-
app.use(session({
24+
app.use(session({
3325
secret: 'ENTER_YOUR_SECRET_HERE',
3426
resave: false,
3527
saveUninitialized: false,
@@ -38,6 +30,17 @@ app.use(session({
3830
}
3931
}));
4032

33+
app.use(express.urlencoded({ extended: false }));
34+
app.use(express.json());
35+
36+
app.set('views', path.join(__dirname, './views'));
37+
app.set('view engine', 'ejs');
38+
39+
app.use('/css', express.static(path.join(__dirname, 'node_modules/bootstrap/dist/css')));
40+
app.use('/js', express.static(path.join(__dirname, 'node_modules/bootstrap/dist/js')));
41+
42+
app.use(express.static(path.join(__dirname, './public')));
43+
4144
// instantiate the wrapper
4245
const msid = new MsIdExpress.WebAppAuthClientBuilder(appSettings).build();
4346

@@ -51,26 +54,24 @@ app.get('/home', mainController.getHomePage);
5154
// authentication routes
5255
app.get('/signin',
5356
msid.signIn({
54-
postLoginRedirect: '/'
57+
postLoginRedirect: '/',
58+
failureRedirect: '/signin'
5559
}
5660
));
5761

5862
app.get('/signout',
5963
msid.signOut({
60-
postLogoutRedirect: '/'
64+
postLogoutRedirect: '/',
6165
}
6266
));
6367

6468
// secure routes
6569
app.get('/id',
66-
msid.isAuthenticated(),
70+
msid.isAuthenticated(),
6771
mainController.getIdPage
6872
);
6973

7074
// unauthorized
71-
app.get('/error', (req, res) => res.redirect('/500.html'));
72-
73-
// error
7475
app.get('/unauthorized', (req, res) => res.redirect('/401.html'));
7576

7677
// 404

1-Authentication/1-sign-in/App/appSettings.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ const appSettings = {
66
},
77
authRoutes: {
88
redirect: "/redirect",
9-
error: "/error", // the wrapper will redirect to this route in case of any error.
109
unauthorized: "/unauthorized" // the wrapper will redirect to this route in case of unauthorized access attempt.
1110
}
1211
}

1-Authentication/1-sign-in/App/controllers/mainController.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
exports.getHomePage = (req, res, next) => {
22
const isAuthenticated = req.session.isAuthenticated;
3-
res.render('home', { isAuthenticated: isAuthenticated });
3+
const username = req.session.account ? req.session.account.username : '';
4+
res.render('home', { isAuthenticated: isAuthenticated, username: username });
45
}
56

67
exports.getIdPage = (req, res, next) => {

0 commit comments

Comments
 (0)