fix urls
This commit is contained in:
parent
7a3c30729b
commit
5871903824
8 changed files with 25 additions and 18 deletions
|
|
@ -3,7 +3,7 @@ import axios from "axios";
|
|||
const { protocol, hostname, port, pathname } = window.location;
|
||||
|
||||
const baseAPI = axios.create({
|
||||
baseURL: protocol + "//" + hostname + (port ? ":" + port : "") + pathname + "/",
|
||||
baseURL: protocol + "//" + hostname + (port ? ":" + port : "") + pathname,
|
||||
});
|
||||
|
||||
// global error handling
|
||||
|
|
|
|||
|
|
@ -220,7 +220,7 @@ func (cp *ConfigProvider) webControl(httpd *server.HTTPd, paramC chan<- util.Par
|
|||
|
||||
// TODO make evccURI configurable, add warnings for any network/ localhost
|
||||
evccURI := fmt.Sprintf("http://%s", httpd.Addr)
|
||||
authURI := fmt.Sprintf("%s/oauth", evccURI)
|
||||
baseAuthURI := fmt.Sprintf("%s/oauth", evccURI)
|
||||
|
||||
var id int
|
||||
for _, v := range cp.vehicles {
|
||||
|
|
@ -228,12 +228,13 @@ func (cp *ConfigProvider) webControl(httpd *server.HTTPd, paramC chan<- util.Par
|
|||
id += 1
|
||||
|
||||
basePath := fmt.Sprintf("vehicles/%d", id)
|
||||
baseURI := fmt.Sprintf("%s/auth/%s", evccURI, basePath)
|
||||
callbackURI := fmt.Sprintf("%s/%s/callback", baseAuthURI, basePath)
|
||||
// baseURI := fmt.Sprintf("%s/oauth/%s", evccURI, basePath)
|
||||
|
||||
// register vehicle
|
||||
ap := cp.auth.Register(baseURI, v.Title())
|
||||
ap := cp.auth.Register(fmt.Sprintf("oauth/%s", basePath), v.Title())
|
||||
|
||||
provider.SetCallbackParams(evccURI, authURI, ap.Handler())
|
||||
provider.SetCallbackParams(evccURI, callbackURI, ap.Handler())
|
||||
|
||||
auth.
|
||||
Methods(http.MethodPost).
|
||||
|
|
@ -243,11 +244,9 @@ func (cp *ConfigProvider) webControl(httpd *server.HTTPd, paramC chan<- util.Par
|
|||
Methods(http.MethodPost).
|
||||
Path(fmt.Sprintf("/%s/logout", basePath)).
|
||||
HandlerFunc(provider.LogoutHandler())
|
||||
}
|
||||
}
|
||||
|
||||
if id > 0 {
|
||||
log.INFO.Printf("ensure the oauth client redirect/callback is configured for: %s", authURI)
|
||||
log.INFO.Printf("ensure the oauth client redirect/callback is configured for %s: %s", v.Title(), callbackURI)
|
||||
}
|
||||
}
|
||||
|
||||
cp.auth.Publish()
|
||||
|
|
|
|||
4
dist/index.html
vendored
4
dist/index.html
vendored
|
|
@ -1,5 +1,5 @@
|
|||
<!DOCTYPE html><html lang="de"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="description" content="EV Charge Controller"><meta name="author" content="andig"><meta name="apple-mobile-web-app-capable" content="yes"><meta name="apple-mobile-web-app-status-bar-style" content="black"><link rel="apple-touch-icon" sizes="180x180" href="ico/apple-touch-icon.png?[[.Version]]"><link rel="icon" type="image/png" sizes="32x32" href="ico/favicon-32x32.png?[[.Version]]"><link rel="icon" type="image/png" sizes="16x16" href="ico/favicon-16x16.png?[[.Version]]"><link rel="manifest" href="ico/site.webmanifest"><link rel="mask-icon" href="ico/safari-pinned-tab.svg?[[.Version]]" color="#18191a"><link rel="shortcut icon" href="ico/favicon.ico?[[.Version]]"><meta name="apple-mobile-web-app-title" content="evcc"><meta name="application-name" content="evcc"><meta name="msapplication-TileColor" content="#18191a"><meta name="msapplication-config" content="ico/browserconfig.xml"><meta name="theme-color" content="#18191a"><title>evcc</title><link href="css/chunk-vendors.4692b1e2.css" rel="preload" as="style"><link href="css/index.fa13361a.css" rel="preload" as="style"><link href="js/chunk-vendors.9a7e7d4f.js" rel="preload" as="script"><link href="js/index.e32b4533.js" rel="preload" as="script"><link href="css/chunk-vendors.4692b1e2.css" rel="stylesheet"><link href="css/index.fa13361a.css" rel="stylesheet"></head><body><script>window.evcc = {
|
||||
<!DOCTYPE html><html lang="de"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="description" content="EV Charge Controller"><meta name="author" content="andig"><meta name="apple-mobile-web-app-capable" content="yes"><meta name="apple-mobile-web-app-status-bar-style" content="black"><link rel="apple-touch-icon" sizes="180x180" href="ico/apple-touch-icon.png?[[.Version]]"><link rel="icon" type="image/png" sizes="32x32" href="ico/favicon-32x32.png?[[.Version]]"><link rel="icon" type="image/png" sizes="16x16" href="ico/favicon-16x16.png?[[.Version]]"><link rel="manifest" href="ico/site.webmanifest"><link rel="mask-icon" href="ico/safari-pinned-tab.svg?[[.Version]]" color="#18191a"><link rel="shortcut icon" href="ico/favicon.ico?[[.Version]]"><meta name="apple-mobile-web-app-title" content="evcc"><meta name="application-name" content="evcc"><meta name="msapplication-TileColor" content="#18191a"><meta name="msapplication-config" content="ico/browserconfig.xml"><meta name="theme-color" content="#18191a"><title>evcc</title><link href="css/chunk-vendors.4692b1e2.css" rel="preload" as="style"><link href="css/index.fa13361a.css" rel="preload" as="style"><link href="js/chunk-vendors.9a7e7d4f.js" rel="preload" as="script"><link href="js/index.fbe6262f.js" rel="preload" as="script"><link href="css/chunk-vendors.4692b1e2.css" rel="stylesheet"><link href="css/index.fa13361a.css" rel="stylesheet"></head><body><script>window.evcc = {
|
||||
version: "[[.Version]]",
|
||||
configured: "[[.Configured]]",
|
||||
commit: "[[.Commit]]",
|
||||
};</script><div id="app"></div><script src="js/chunk-vendors.9a7e7d4f.js"></script><script src="js/index.e32b4533.js"></script></body></html>
|
||||
};</script><div id="app"></div><script src="js/chunk-vendors.9a7e7d4f.js"></script><script src="js/index.fbe6262f.js"></script></body></html>
|
||||
2
dist/js/index.e32b4533.js
vendored
2
dist/js/index.e32b4533.js
vendored
File diff suppressed because one or more lines are too long
1
dist/js/index.e32b4533.js.map
vendored
1
dist/js/index.e32b4533.js.map
vendored
File diff suppressed because one or more lines are too long
2
dist/js/index.fbe6262f.js
vendored
Normal file
2
dist/js/index.fbe6262f.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/js/index.fbe6262f.js.map
vendored
Normal file
1
dist/js/index.fbe6262f.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
|
|
@ -67,17 +67,25 @@ func (a *Auth) handle(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
state, err := util.DecryptState(vars["state"], a.secret)
|
||||
if err == nil {
|
||||
err = state.Validate()
|
||||
if err != nil {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
fmt.Fprintf(w, "failed to decrypt state")
|
||||
return
|
||||
}
|
||||
|
||||
if err := state.Validate(); err != nil {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
fmt.Fprintf(w, "invalid state")
|
||||
return
|
||||
}
|
||||
|
||||
a.mu.Lock()
|
||||
handler := a.routes[vars["state"]]
|
||||
a.mu.Unlock()
|
||||
|
||||
if err != nil || handler == nil {
|
||||
if handler == nil {
|
||||
w.WriteHeader(http.StatusBadRequest)
|
||||
fmt.Fprintf(w, "invalid state")
|
||||
fmt.Fprintf(w, "no handler found")
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue