Skip to content

Commit

Permalink
Clean up old use of 'var'
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Cunningham <[email protected]>
  • Loading branch information
digitaldan committed May 23, 2024
1 parent ab64285 commit af8e3fa
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions routes/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var system = require('../system'),
const system = require('../system'),
homepage = require('./homepage'),
passport = require('passport'),
account_routes = require('./account'),
Expand All @@ -24,7 +24,7 @@ var system = require('../system'),
* @param {logger} logger
* @constructor
*/
var Routes = function (logger) {
const Routes = function (logger) {
this.logger = logger;
};

Expand Down Expand Up @@ -76,14 +76,8 @@ Routes.prototype.setupLoginLogoutRoutes = function (app) {
});

app.get('/login', function (req, res) {
var errormessages = req.flash('error'),
invitationCode;

if (req.query['invitationCode'] !== null) {
invitationCode = req.query['invitationCode'];
} else {
invitationCode = '';
}
const errormessages = req.flash('error');
const invitationCode = req.query['invitationCode'] !== null ? req.query['invitationCode'] : '';

res.render('login', {
title: 'Log in',
Expand Down Expand Up @@ -132,7 +126,7 @@ Routes.prototype.setupApplicationsRoutes = function (app) {
};

Routes.prototype.setupNewUserRegistrationRoutes = function (app) {
var registerPostValidate = account_routes.registerpostvalidateall;
let registerPostValidate = account_routes.registerpostvalidateall;

if (!system.hasLegalTerms() && !system.hasLegalPolicy()) {
registerPostValidate = account_routes.registerpostvalidate;
Expand Down Expand Up @@ -294,7 +288,7 @@ Routes.prototype.ensureServer = function (req, res, next) {
};

Routes.prototype.setOpenhab = function (req, res, next) {
var self = this;
const self = this;

//ignore if no authentication
if (!req.isAuthenticated()) {
Expand Down Expand Up @@ -351,7 +345,7 @@ Routes.prototype.preassembleBody = function (req, res, next) {
//app.js will catch any JSON or URLEncoded related requests and
//store the rawBody on the request, all other requests need
//to have that data collected and stored here
var data = '';
let data = '';
if (req.rawBody === undefined || req.rawBody === "") {
req.on('data', function (chunk) {
data += chunk;
Expand All @@ -367,17 +361,17 @@ Routes.prototype.preassembleBody = function (req, res, next) {
};

Routes.prototype.proxyRouteOpenhab = function (req, res) {
var self = this;
const self = this;

this.logger.auditRequest(req);
req.connection.setTimeout(600000);

//tell OH3 to use alternative Authentication header
res.cookie('X-OPENHAB-AUTH-HEADER', 'true')

var requestId = this.requestTracker.acquireRequestId();
const requestId = this.requestTracker.acquireRequestId();
// make a local copy of request headers to modify
var requestHeaders = req.headers;
const requestHeaders = req.headers;
// We need to remove and modify some headers here
delete requestHeaders['cookie'];
delete requestHeaders['cookie2'];
Expand All @@ -389,7 +383,7 @@ Routes.prototype.proxyRouteOpenhab = function (req, res) {
requestHeaders['host'] = req.headers.host || system.getHost() + ':' + system.getPort();
requestHeaders['user-agent'] = 'openhab-cloud/0.0.1';
// Strip off path prefix for remote vhosts hack
var requestPath = req.path;
let requestPath = req.path;
if (requestPath.indexOf('/remote/') === 0) {
requestPath = requestPath.replace('/remote', '');
// TODO: this is too dirty :-(
Expand Down

0 comments on commit af8e3fa

Please sign in to comment.