Sync shared snapshot from 3131937
Docker / Docker Build & Push (push) Successful in 4m1s

This commit is contained in:
Gabriel20xx committed 2026-09-09 22:25:06 +02:00
1 parent fc24ae2f60
commit 20e9461d46
1 file changed
+15 -5
+15 -5
View File
@@ -531,17 +531,27 @@ func (s *Service) UpdateAccessSettings(w http.ResponseWriter, r *http.Request) {
writeError(w, http.StatusBadRequest, "loginRequired must be a boolean")
return
}
if _, err := s.db.Exec(r.Context(), `
INSERT INTO settings (key, value, updated_at)
VALUES ($1, $2, NOW())
ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value, updated_at = NOW()
`, loginRequiredSettingKey, strconv.FormatBool(*input.LoginRequired)); err != nil {
if err := s.SetLoginRequired(r.Context(), *input.LoginRequired); err != nil {
writeError(w, http.StatusInternalServerError, "access setting could not be saved")
return
}
writeJSON(w, http.StatusOK, map[string]bool{"loginRequired": *input.LoginRequired})
}
// SetLoginRequired writes the auth_required flag directly, the same one UpdateAccessSettings
// exposes to a manager-authenticated session - callers reach this from an X-Internal-Auth-gated
// route instead (see each service's own setLoginRequiredInternal), letting ProjectConfigurator's
// central "Require Login" toggle (ConfigWorkspace.svelte's loginControls) apply here without an
// admin session of its own.
func (s *Service) SetLoginRequired(ctx context.Context, required bool) error {
_, err := s.db.Exec(ctx, `
INSERT INTO settings (key, value, updated_at)
VALUES ($1, $2, NOW())
ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value, updated_at = NOW()
`, loginRequiredSettingKey, strconv.FormatBool(required))
return err
}
func (s *Service) Status(w http.ResponseWriter, r *http.Request) {
if !s.enabled() {
user := localProfile