mirror of
https://github.com/amir20/dozzle.git
synced 2025-12-24 14:31:44 +01:00
fix: removes any configuration from index.html when users are not authenticated (#2889)
This commit is contained in:
@@ -50,8 +50,7 @@ let form: HTMLFormElement | undefined = $ref();
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
|
||||
async function onLogin() {
|
||||
const url = config.authProvider === "simple" ? "/api/token" : "/api/validateCredentials";
|
||||
const response = await fetch(withBase(url), {
|
||||
const response = await fetch(withBase("/api/token"), {
|
||||
body: new FormData(form),
|
||||
method: "POST",
|
||||
});
|
||||
|
||||
@@ -29,6 +29,8 @@ const pageConfig = JSON.parse(text);
|
||||
|
||||
const config: Config = {
|
||||
maxLogs: 600,
|
||||
version: "v0.0.0",
|
||||
hosts: [],
|
||||
...pageConfig,
|
||||
};
|
||||
|
||||
|
||||
@@ -52,15 +52,19 @@ func (h *handler) executeTemplate(w http.ResponseWriter, req *http.Request) {
|
||||
})
|
||||
|
||||
config := map[string]interface{}{
|
||||
"base": base,
|
||||
"version": h.config.Version,
|
||||
"hostname": h.config.Hostname,
|
||||
"hosts": hosts,
|
||||
"authProvider": h.config.Authorization.Provider,
|
||||
"enableActions": h.config.EnableActions,
|
||||
"base": base,
|
||||
}
|
||||
|
||||
user := auth.UserFromContext(req.Context())
|
||||
|
||||
if h.config.Authorization.Provider == NONE || user != nil {
|
||||
config["authProvider"] = h.config.Authorization.Provider
|
||||
config["version"] = h.config.Version
|
||||
config["hostname"] = h.config.Hostname
|
||||
config["hosts"] = hosts
|
||||
config["enableActions"] = h.config.EnableActions
|
||||
}
|
||||
|
||||
if user != nil {
|
||||
if profile, err := profile.Load(*user); err == nil {
|
||||
config["profile"] = profile
|
||||
|
||||
2
public/robots.txt
Normal file
2
public/robots.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
User-agent: *
|
||||
Disallow: /
|
||||
Reference in New Issue
Block a user