From b636d4524eb74d69df9161651564524cc26112fb Mon Sep 17 00:00:00 2001
From: Rosanny <rosanny.sihombing@hft-stuttgart.de>
Date: Wed, 10 Jun 2020 10:00:22 +0200
Subject: [PATCH] update readme

---
 README.md | 27 +++++++++++++++++++++++++--
 1 file changed, 25 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 8e5929423..90595d30a 100644
--- a/README.md
+++ b/README.md
@@ -8,7 +8,30 @@ There are 2 options:
 2. Use view engine to enable having if-else conditions on 1 page
    - This is the option I take for this project.
    - You need to get familiar with the view engine. I use pug (https://pugjs.org/api/getting-started.html) on this project.
-   - You can convert your existing html page to pug using this website: https://html-to-pug.com/. I have tried it to convert index.html to index.pug and it works.
+   - You can convert your existing html page to pug using this website: https://html-to-pug.com/. I have tried it to convert index.html(https://gitlab.com/Cholgrrr/m4labplatform/-/blob/sso/vcm/index.html) to index.pug(https://gitlab.com/Cholgrrr/m4labplatform/-/blob/sso/vcm/index.pug) and it works.
+   - Example on this project:
+     define the route on server.js:
+     app.get('/index', function (req, res) {
+        if (req.isAuthenticated()) {
+          res.render('index', {
+            userLogin: true
+          })
+        } else {
+          res.render('index', {
+            userLogin: false
+          })
+        }
+     })
+     then use the userLogin parameter in the if-else condition on index.pug:
+     if userLogin == true
+        button#tourstart-btn.buttonset.one(onclick='stopStory()')
+          span.i18n_balloon_startscreen_btn Start
+     else
+        button
+          span.i18n_balloon_startscreen_btn Login
 
 ### Preventing user to directly access an html
-to be continued
\ No newline at end of file
+If you choose option 1 and want to prevent users to directly access an html, you can try to redirect them to any page you want just like the following:
+app.get('/index.html', function (req, res) {
+    res.redirect('/index')
+})
-- 
GitLab