diff --git a/app/routes.js b/app/routes.js index 31f3326..60a40eb 100644 --- a/app/routes.js +++ b/app/routes.js @@ -11,5 +11,6 @@ require('./routes/vaccines')(router) require('./routes/reports')(router) require('./routes/prototype-admin')(router) require('./routes/support')(router) +require('./routes/auth')(router) module.exports = router; diff --git a/app/routes/auth.js b/app/routes/auth.js new file mode 100644 index 0000000..133330e --- /dev/null +++ b/app/routes/auth.js @@ -0,0 +1,33 @@ +module.exports = router => { + + router.post('/select-organisation', (req, res) => { + const organisationId = req.session.data.organisationId + + if (organisationId) { + req.session.data.currentUserId = "12345"; + + // Reset data + delete req.session.data.organisationId + req.session.data.multiOrganisation = "no" + + res.redirect('/find-a-patient') + } else { + + const error = { + text: "Select an organisation", + href: "#organisationId-1" + } + + res.render('select-organisation', { + error + }) + } + }) + + router.get('/sign-out', (req, res) => { + req.session.data.currentUserId = null + + res.redirect('/home') + }) + +} diff --git a/app/views/home.html b/app/views/home.html new file mode 100644 index 0000000..028852a --- /dev/null +++ b/app/views/home.html @@ -0,0 +1,27 @@ +{% extends 'layout.html' %} + +{% block pageTitle %} + Record a vaccination +{% endblock %} + +{% block header %} + {% include "includes/header-logged-out.html" %} +{% endblock %} + +{% block content %} +
+
+ +

Welcome to Record a vaccination service (RAVS)

+ +

You are not signed in.

+ + {{ button({ + text: "Log in", + href: "/okta-sign-in" + }) }} + +
+
+ +{% endblock %} diff --git a/app/views/includes/header-logged-in-organisation.html b/app/views/includes/header-logged-in-organisation.html index 50c5629..8311733 100644 --- a/app/views/includes/header-logged-in-organisation.html +++ b/app/views/includes/header-logged-in-organisation.html @@ -33,9 +33,9 @@ classes: "app-header__navigation-item--right-aligned " + ("app-header__navigation-item--current" if currentSection == "user-profile") }, { - url: '/', + url: '/sign-out', label: 'Log out' } - ] + ] if data.currentUserId }) }} diff --git a/app/views/includes/header-logged-in-region.html b/app/views/includes/header-logged-in-region.html index 1694e91..32663bb 100644 --- a/app/views/includes/header-logged-in-region.html +++ b/app/views/includes/header-logged-in-region.html @@ -13,7 +13,7 @@ classes: "app-header__navigation-item--right-aligned " + ("app-header__navigation-item--current" if currentSection == "user-profile") }, { - url: '/', + url: '/sign-out', label: 'Log out' } ] diff --git a/app/views/includes/header-logged-in-support.html b/app/views/includes/header-logged-in-support.html index e70f87c..300652e 100644 --- a/app/views/includes/header-logged-in-support.html +++ b/app/views/includes/header-logged-in-support.html @@ -18,7 +18,7 @@ classes: "app-header__navigation-item--right-aligned " + ("app-header__navigation-item--current" if currentSection == "user-profile") }, { - url: '/', + url: '/sign-out', label: 'Log out' } ] diff --git a/app/views/index.html b/app/views/index.html index 28151a6..b46c588 100755 --- a/app/views/index.html +++ b/app/views/index.html @@ -38,6 +38,9 @@

Main interface

+

Homepage

+

Homepage - sign in as a user belonging to 2 organisations

+