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 %} +
You are not signed in.
+ + {{ button({ + text: "Log in", + href: "/okta-sign-in" + }) }} + +Homepage - sign in as a user belonging to 2 organisations
+