salix/@salix-services/app/server/boot/routes.js

41 lines
854 B
JavaScript
Raw Normal View History

2016-11-07 10:20:04 +00:00
module.exports = function(app) {
2016-11-04 10:32:27 +00:00
2016-11-07 10:20:04 +00:00
app.get('/',function(req,res){
2016-11-04 10:32:27 +00:00
2016-11-07 10:20:04 +00:00
if (req.cookies['salix-session']){
res.render('index.ejs');
}
else{
res.status(401);
res.send("No autorizado");
}
});
//https://github.com/expressjs/cookie-parser
app.get('/login', function(req, res) {
2016-11-04 10:32:27 +00:00
var token = req.query.access_token;
2016-11-07 10:20:04 +00:00
if (token) {
res.cookie('salix-session', token, { httpOnly: true });
res.redirect('/');
2016-11-04 10:32:27 +00:00
}
else {
2016-11-07 10:20:04 +00:00
res.redirect('/login1');
}
});
app.get('/config.js',(req,res)=>{
if (req.cookies['salix-session']){
res.set('Content-Type', 'application/json');
//TODO: construir js dinamico de las rutas
res.status(404);
res.send();
}
else{
res.status(401);
res.send("No autorizado");
2016-11-04 10:32:27 +00:00
}
});
2016-11-07 10:20:04 +00:00
2016-11-04 10:32:27 +00:00
};