greenbot-sdk
Advanced tools
Comparing version 1.0.16 to 1.0.17
29
index.js
@@ -116,3 +116,3 @@ const MongoClient = require('mongodb').MongoClient; | ||
const updateConfig = async function(request, response) { | ||
const updateConfig = async function (request, response) { | ||
await saveConfigData(request.body); | ||
@@ -122,3 +122,3 @@ response.redirect('/config'); | ||
const updateConfigJson = async function(request, response) { | ||
const updateConfigJson = async function (request, response) { | ||
const error = await saveConfigData(request.body); | ||
@@ -148,3 +148,3 @@ | ||
const clearCollection = async function(request, response) { | ||
const clearCollection = async function (request, response) { | ||
if (!client) { | ||
@@ -168,3 +168,3 @@ return; | ||
const getConfig = async function(request, response) { | ||
const getConfig = async function (request, response) { | ||
config = request.config; | ||
@@ -201,3 +201,3 @@ delete config._id; | ||
return result.sort(function(a, b) { | ||
return result.sort(function (a, b) { | ||
return a.name > b.name ? 1 : a.name < b.name ? -1 : 0; | ||
@@ -211,3 +211,3 @@ }); | ||
const getConfigJson = async function(request, response) { | ||
const getConfigJson = async function (request, response) { | ||
config = request.config; | ||
@@ -220,3 +220,3 @@ delete config._id; | ||
const getMetaData = async function(request, response) { | ||
const getMetaData = async function (request, response) { | ||
const metaData = require('./package.json'); | ||
@@ -228,3 +228,3 @@ | ||
const notifyReq = async function(request, response) { | ||
const notifyReq = async function (request, response) { | ||
notify(request.body.cell, request.body.text); | ||
@@ -274,6 +274,7 @@ response.redirect('/'); | ||
const checkPassword = function(req, res, next) { | ||
const checkPassword = function (req, res, next) { | ||
if (req.config.password) { | ||
if (!req.session.authorized) { | ||
if (req.path != reqPath) { | ||
console.log('login...'); | ||
res.redirect(reqPath); | ||
@@ -286,7 +287,7 @@ } | ||
const loginPage = function(req, res, next) { | ||
const loginPage = function (req, res, next) { | ||
res.render('login'); | ||
}; | ||
const loginValidate = function(req, res, next) { | ||
const loginValidate = function (req, res, next) { | ||
if (req.body.password == req.config.password) { | ||
@@ -301,3 +302,3 @@ req.session.authorized = true; | ||
const logout = function(req, res, next) { | ||
const logout = function (req, res, next) { | ||
req.session = null; | ||
@@ -369,3 +370,3 @@ res.redirect(reqPath); | ||
app.use('/', trace); | ||
app.get('/log', function(request, response) { | ||
app.get('/log', function (request, response) { | ||
response.render('log'); | ||
@@ -377,3 +378,3 @@ }); | ||
// check visitors at the door | ||
app.use(checkPassword); | ||
app.get(checkPassword); | ||
app.get(reqPath, loginPage); | ||
@@ -380,0 +381,0 @@ app.post(reqPath, loginValidate); |
{ | ||
"name": "greenbot-sdk", | ||
"version": "1.0.16", | ||
"version": "1.0.17", | ||
"description": "An Express Framework for automations", | ||
@@ -31,2 +31,2 @@ "main": "index.js", | ||
} | ||
} | ||
} |
15761
337