Adding authentication

This commit is contained in:
Manuel Romero
2020-09-16 12:59:08 +02:00
parent dc8cae1853
commit c5a9cbde58
2 changed files with 8 additions and 2 deletions

1
costexport/sample.json Normal file
View File

@@ -0,0 +1 @@
{"test": "ok"}

View File

@@ -71,7 +71,6 @@ app.use(cookieParser());
app.use(bodyParser.urlencoded({ extended: false }))
// parse application/json
app.use(bodyParser.json())
app.use('/costexport', passport.ensureAuthenticatedAndAdmin, express.static(__dirname + '/../costexport') );
app.use('/',express.static(__dirname + '/../dist/qmi-cloud'));
passport.init(app);
@@ -157,7 +156,13 @@ const options = {
};
app.use('/costexport*', passport.ensureAuthenticatedAndAdmin, function(req, res){
if ( !req.query.file ) {
res.status(404).send("Not found");
} else {
res.sendFile(path.resolve(__dirname, '..', 'costexport', req.query.file ));
}
} );
const specs = swaggerJsdoc(options);
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(specs));