Remote Access: not experimental any more (#33148)
This commit is contained in:
parent
10c646e668
commit
442113e9ea
8 changed files with 65 additions and 11 deletions
|
|
@ -15,6 +15,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/evcc-io/evcc/api"
|
||||
"github.com/evcc-io/evcc/core/keys"
|
||||
"github.com/evcc-io/evcc/core/loadpoint"
|
||||
"github.com/evcc-io/evcc/core/site"
|
||||
"github.com/evcc-io/evcc/server/assets"
|
||||
|
|
@ -528,6 +529,7 @@ func resetDatabase(shutdown func()) http.HandlerFunc {
|
|||
var req struct {
|
||||
Sessions bool `json:"sessions"`
|
||||
Settings bool `json:"settings"`
|
||||
Remote bool `json:"remote"`
|
||||
}
|
||||
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
|
||||
jsonError(w, http.StatusBadRequest, err)
|
||||
|
|
@ -560,6 +562,15 @@ func resetDatabase(shutdown func()) http.HandlerFunc {
|
|||
}
|
||||
}
|
||||
|
||||
if req.Remote {
|
||||
for _, key := range []string{keys.Remote, keys.RemoteClients, keys.RemoteLastSeen} {
|
||||
if err := settings.Delete(key); err != nil {
|
||||
jsonError(w, http.StatusInternalServerError, err)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// close db connection to avoid on-shutdown writes
|
||||
if err := db.Close(); err != nil {
|
||||
jsonError(w, http.StatusInternalServerError, err)
|
||||
|
|
|
|||
6
server/mcp/openapi.json
generated
6
server/mcp/openapi.json
generated
|
|
@ -2197,7 +2197,7 @@
|
|||
"post": {
|
||||
"operationId": "resetDatabase",
|
||||
"summary": "Reset database",
|
||||
"description": "Selectively deletes sessions and/or settings from the database. Session users must supply the admin password in the X-Admin-Password header. API key holders via Bearer token are exempt. The instance restarts after a successful reset.",
|
||||
"description": "Selectively deletes sessions, settings and/or remote access data from the database. Session users must supply the admin password in the X-Admin-Password header. API key holders via Bearer token are exempt. The instance restarts after a successful reset.",
|
||||
"tags": [
|
||||
"db"
|
||||
],
|
||||
|
|
@ -2228,6 +2228,10 @@
|
|||
"settings": {
|
||||
"type": "boolean",
|
||||
"description": "Delete all settings, configs, and meters"
|
||||
},
|
||||
"remote": {
|
||||
"type": "boolean",
|
||||
"description": "Delete remote access configuration and registered clients"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1327,7 +1327,7 @@ paths:
|
|||
post:
|
||||
operationId: resetDatabase
|
||||
summary: Reset database
|
||||
description: "Selectively deletes sessions and/or settings from the database. Session users must supply the admin password in the X-Admin-Password header. API key holders via Bearer token are exempt. The instance restarts after a successful reset."
|
||||
description: "Selectively deletes sessions, settings and/or remote access data from the database. Session users must supply the admin password in the X-Admin-Password header. API key holders via Bearer token are exempt. The instance restarts after a successful reset."
|
||||
tags:
|
||||
- db
|
||||
security:
|
||||
|
|
@ -1348,6 +1348,9 @@ paths:
|
|||
settings:
|
||||
type: boolean
|
||||
description: Delete all settings, configs, and meters
|
||||
remote:
|
||||
type: boolean
|
||||
description: Delete remote access configuration and registered clients
|
||||
responses:
|
||||
"204":
|
||||
description: Reset successful, instance is restarting
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue