diff --git a/dht.js b/dht.js index f8a47f1..856a659 100644 --- a/dht.js +++ b/dht.js @@ -201,7 +201,7 @@ wss.on('connection', ws => { var mosca = require('mosca'); var mqtt_settings = { - port:1884, + port:1883, secure : { port: 8444, keyPath: SECURE_KEY, @@ -230,6 +230,7 @@ mqtt_client.on('connect', function () { // mqtt_client.subscribe('dht'); // mqtt_client.subscribe('ir'); + // ESP_Easy_0 = garden mqtt_client.subscribe('Garden/+'); mqtt_client.subscribe('Garden/+/+'); mqtt_client.publish('tasmota', 'controller connected'); diff --git a/server.js b/server.js index 062a023..4b60eb2 100644 --- a/server.js +++ b/server.js @@ -76,22 +76,22 @@ app.get('/login', }); app.post('/login', - passport.authenticate('local', { failureRedirect: config.localPath+ '/login' }), + passport.authenticate('local', { failureRedirect: '/login' }), function(req, res) { - res.redirect(config.localPath+ '/'); + res.redirect('/'); }); app.get('/logout', function(req, res){ req.logout(); - res.redirect(config.localPath+ '/'); + res.redirect('/'); }); app.get('/accontrol', // passport.authenticate('local', { - // failureRedirect: config.localPath+ '/login' , - // successRedirect: config.localPath+ '/accontrol'}), - require('connect-ensure-login').ensureLoggedIn(config.localPath+ '/login'), + // failureRedirect: '/login' , + // successRedirect: '/accontrol'}), + require('connect-ensure-login').ensureLoggedIn('/login'), function(req, res){ res.render('accontrol', { user: req.user }); }); diff --git a/src/auth.js b/src/auth.js index 69035d4..42b1f74 100644 --- a/src/auth.js +++ b/src/auth.js @@ -15,13 +15,13 @@ var CookieStrategy = require('passport-cookie').Strategy; var session = require('express-session'); const cookierParser = require('cookie-parser'); -var ensureLoggedIn = require("connect-ensure-login").ensureLoggedIn(config.localPath + "/login"); +var ensureLoggedIn = require("connect-ensure-login").ensureLoggedIn("/login"); module.exports = { ensureLoggedIn_Orig: ensureLoggedIn, ensureLoggedIn_P: function (req, res, next){passport.authenticate('local', { - successRedirect: config.localPath + '/accontrol', - failureRedirect: config.localPath + '/login' })}, + successRedirect: '/accontrol', + failureRedirect: '/login' })}, passport: passport, ensureLoggedIn_New: function (req, res, next) { if (req.isAuthenticated()) { @@ -123,8 +123,8 @@ module.exports = { app.post('/login', passport.authenticate('local', { - successRedirect: config.localPath + '/accontrol', - failureRedirect: config.localPath + '/login' }), + successRedirect: '/accontrol', + failureRedirect: '/login' }), // authenticated user. function(req, res) { console.log("logged in. session:" + req.session); @@ -134,7 +134,7 @@ module.exports = { app.get('/logout', function(req, res){ req.logout(); - res.redirect(config.localPath + '/login'); + res.redirect( '/login'); }); return app; diff --git a/views/accontrol.ejs b/views/accontrol.ejs index 8ddea5a..0bd47a9 100644 --- a/views/accontrol.ejs +++ b/views/accontrol.ejs @@ -1,7 +1,7 @@

AC Control for <% if (model.user) {model.user.username; } %>

Retrieving current conditions...

-
+
data-toggle='toggle' data-style='android' data-on='ON' data-off='Off' /> @@ -34,7 +34,7 @@ INFO: <%- contentFor('head') %> diff --git a/views/chartGarden.ejs b/views/chartGarden.ejs index 70b3573..df2ed38 100644 --- a/views/chartGarden.ejs +++ b/views/chartGarden.ejs @@ -20,11 +20,11 @@ Period
@@ -224,10 +224,10 @@ chart.render(); } - $.getJSON(config.localPath + "/device/A23_DHT/<%= model.days ? model.days : '7' %>", addData); - $.getJSON(config.localPath + "/device/A23_Garden_dht/<%= model.days ? model.days : '7' %>", addData); + $.getJSON("/device/A23_DHT/<%= model.days ? model.days : '7' %>", addData); + $.getJSON("/device/A23_Garden_dht/<%= model.days ? model.days : '7' %>", addData); setTimeout(function(){ - $.getJSON(config.localPath + "/dht?e=now", function(data){ + $.getJSON("/dht?e=now", function(data){ if(data && data.dht){ $("#now").text("In A23 currently is " + data.dht.temp + "°C, " + data.dht.hum +"% RH" ); }else { @@ -236,7 +236,7 @@ }); },5000); - $("#water").on("click", function(){$.ajax({url:config.localPath + "/water?t="+$("#waterTime").val()});}); - $("#waterStop").on("click", function(){$.ajax({url:config.localPath + "/waterStop"});}); + $("#water").on("click", function(){$.ajax({url:"/water?t="+$("#waterTime").val()});}); + $("#waterStop").on("click", function(){$.ajax({url: "/waterStop"});}); } \ No newline at end of file diff --git a/views/layout.ejs b/views/layout.ejs index 1fc8244..ca3218f 100644 --- a/views/layout.ejs +++ b/views/layout.ejs @@ -5,7 +5,7 @@ ESP8266 Weather Server - +