var express = require('express'); var route = express.Router(); route.get('/login', (req, res) => { // TODO: login let a = global['modules'].sso.createAuthentication({ url: global['gds'].cfg.sso.authenticator, appId: global['gds'].cfg.sso.appId }); res.redirect(a); }); route.get('/authenticate', (req, res) => { // TODO: authenticate res.end(); }); route.get('/logout', (req, res) => { if(!req.session.user) { return res.type('json').end(JSON.stringify({ status: 401, message: 'msg.auth.login.required' })); } else { res.clearCookie('RememberMe'); req.session.destroy(); return res.type('json').end(JSON.stringify({ status: 200, message: 'msg.auth.logout.successful' })); } }); if(global['gds'].debug) { // DEBUG info route.get('/info', (req, res) => { let obj = {}; if(req.session) obj.session = req.session; if(req.cookies) obj.cookie = req.cookies; res.type('json').end(JSON.stringify(obj)); }); } module.exports = route;