diff --git a/html/index.html b/html/index.html
index 4c2e45d..7a7dbef 100644
--- a/html/index.html
+++ b/html/index.html
@@ -9,12 +9,9 @@
-
+
diff --git a/html/js/thermostat.js b/html/js/thermostat.js
index 136b9ff..053f087 100644
--- a/html/js/thermostat.js
+++ b/html/js/thermostat.js
@@ -114,15 +114,5 @@ function renderThermostats() {
});
};
-function renderVersion() {
- $.ajax({
- url: jsconfig.baseurl + "/api/version"
- }).then(function(data) {
- var versionText = "TempGopher © 2018 Mike Shoup | Version: " + data.version;
- $("#version").text(versionText);
- });
-};
-$(document).ready(renderVersion);
-
$(document).ready(renderThermostats);
var rtHandle = window.setInterval(renderThermostats, 60000);
diff --git a/html/js/version.js b/html/js/version.js
new file mode 100644
index 0000000..0c7d462
--- /dev/null
+++ b/html/js/version.js
@@ -0,0 +1,9 @@
+function renderVersion() {
+ $.ajax({
+ url: jsconfig.baseurl + "/api/version"
+ }).then(function(data) {
+ var versionText = "TempGopher © 2018 Mike Shoup | Version: " + data.version;
+ $("#version").text(versionText);
+ });
+};
+$(document).ready(renderVersion);
diff --git a/html/login.html b/html/login.html
new file mode 100644
index 0000000..377f442
--- /dev/null
+++ b/html/login.html
@@ -0,0 +1,40 @@
+
+
+
+
+
Temp Gopher
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/web.go b/web.go
index b71e094..da3c8ae 100644
--- a/web.go
+++ b/web.go
@@ -126,16 +126,20 @@ func SetupRouter(config *Config, states *map[string]State) *gin.Engine {
r.GET("/ping", PingHandler)
// API Endpoints
- api := r.Group("/api", gin.BasicAuth(GetGinAccounts(config)))
- {
- api.GET("/status", StatusHandler(states))
- api.GET("/status/*alias", StatusHandler(states))
- api.GET("/version", VersionHandler)
- api.GET("/config", ConfigHandler(config))
- api.GET("/config/sensors/*alias", ConfigHandler(config))
- api.POST("/config/sensors", UpdateSensorsHandler)
+ var api *gin.RouterGroup
+ if len(config.Users) == 0 {
+ api = r.Group("/api")
+ } else {
+ api = r.Group("/api", gin.BasicAuth(GetGinAccounts(config)))
}
+ api.GET("/status", StatusHandler(states))
+ api.GET("/status/*alias", StatusHandler(states))
+ api.GET("/version", VersionHandler)
+ api.GET("/config", ConfigHandler(config))
+ api.GET("/config/sensors/*alias", ConfigHandler(config))
+ api.POST("/config/sensors", UpdateSensorsHandler)
+
// App
r.GET("/jsconfig.js", JSConfigHandler(config))
r.StaticFS("/app", GetBox())