proxyauth: render as ejs tos end app title and icon
This commit is contained in:
+20
-3
@@ -7,7 +7,8 @@ exports = module.exports = {
|
||||
stop
|
||||
};
|
||||
|
||||
const assert = require('assert'),
|
||||
const apps = require('./apps.js'),
|
||||
assert = require('assert'),
|
||||
constants = require('./constants.js'),
|
||||
debug = require('debug')('box:proxyAuth'),
|
||||
express = require('express'),
|
||||
@@ -20,6 +21,7 @@ const assert = require('assert'),
|
||||
middleware = require('./middleware'),
|
||||
path = require('path'),
|
||||
paths = require('./paths.js'),
|
||||
safe = require('safetydance'),
|
||||
users = require('./users.js');
|
||||
|
||||
let gHttpServer = null;
|
||||
@@ -44,8 +46,21 @@ function jwtVerify(req, res, next) {
|
||||
});
|
||||
}
|
||||
|
||||
function loginPage(req, res) {
|
||||
return res.sendFile(path.join(paths.DASHBOARD_DIR, 'proxyauth-login.html'));
|
||||
function loginPage(req, res, next) {
|
||||
const appId = req.headers['x-app-id'] || '';
|
||||
if (!appId) return next(new HttpError(503, 'Nginx misconfiguration'));
|
||||
|
||||
apps.get(appId, function (error, app) {
|
||||
if (error) return next(new HttpError(503, error.message));
|
||||
|
||||
const title = app.label || app.manifest.title;
|
||||
|
||||
apps.getIconPath(app, {}, function (error, iconPath) {
|
||||
const icon = safe.fs.readFileSync(iconPath || '', 'base64');
|
||||
|
||||
return res.render(path.join(paths.DASHBOARD_DIR, 'templates/proxyauth-login.ejs'), { title, icon });
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// called by nginx to authorize any protected route
|
||||
@@ -119,6 +134,8 @@ function initializeAuthwallExpressSync() {
|
||||
var router = new express.Router();
|
||||
router.del = router.delete; // amend router.del for readability further on
|
||||
|
||||
app.set('view engine', 'ejs');
|
||||
|
||||
app
|
||||
.use(middleware.timeout(REQUEST_TIMEOUT))
|
||||
.use(middleware.cookieParser())
|
||||
|
||||
Reference in New Issue
Block a user